diff --git a/custom_components/neerslag/__init__.py b/custom_components/neerslag/__init__.py
index 2e9642d..1cc7e09 100644
--- a/custom_components/neerslag/__init__.py
+++ b/custom_components/neerslag/__init__.py
@@ -8,8 +8,6 @@
from .const import DOMAIN
-# TODO List the platforms that you want to support.
-# For your initial PR, limit it to 1 platform.
PLATFORMS = ["sensor"]
_LOGGER = logging.getLogger(__name__)
@@ -19,10 +17,6 @@ async def options_update_listener(hass: HomeAssistant, config_entry: ConfigEntry
"""Handle options update."""
_LOGGER.info("----------------This is being executed-------options_update_listener----------------")
- # await hass.config_entries.async_remove(config_entry.entry_id)
- # rr = hass.config_entries.async_entries(DOMAIN)
- # hass.config_entries.async_update_entry(config_entry, data=config_entry.options)
- # await hass.config_entries.async_reload(config_entry.entry_id)
hass.config_entries.async_update_entry(config_entry, data=config_entry.options)
@@ -37,15 +31,13 @@ async def async_setup(hass: HomeAssistant, config_entry: dict):
async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry):
"""Set up Neerslag Sensor (Buienalarm / Buienradar) from a config entry."""
- # hass.states.async_set("neerslag_sensor.useBuienalarm", ConfigEntry.)
-
- # TODO Store an API object for your platforms to access
- # hass.data[DOMAIN][entry.entry_id] = MyApi(...)
hass.data[DOMAIN][config_entry.entry_id] = {}
hass_data = dict(config_entry.data)
+
# Registers update listener to update config entry when options are updated.
unsub_options_update_listener = config_entry.add_update_listener(options_update_listener)
+
# Store a reference to the unsubscribe function to cleanup if an entry is unloaded.
hass_data["unsub_options_update_listener"] = unsub_options_update_listener
hass.data[DOMAIN][config_entry.entry_id] = hass_data
@@ -60,7 +52,6 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry):
async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry):
# Remove options_update_listener.
-
_LOGGER.info("REMOVE ><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
"""Unload a config entry."""
diff --git a/custom_components/neerslag/config_flow.py b/custom_components/neerslag/config_flow.py
index c7096ae..b103a45 100644
--- a/custom_components/neerslag/config_flow.py
+++ b/custom_components/neerslag/config_flow.py
@@ -11,7 +11,6 @@
_LOGGER = logging.getLogger(__name__)
-# TODO adjust the data schema to the data that you need
STEP_USER_DATA_SCHEMA = vol.Schema({vol.Optional("buienalarm", default=False): bool,
vol.Optional("buienalarmLatitude", description={"suggested_value": "55.000"}): str,
vol.Optional("buienalarmLongitude", description={"suggested_value": "5.000"}): str,
@@ -27,23 +26,6 @@ async def validate_input(hass: core.HomeAssistant, data):
Data has the keys from STEP_USER_DATA_SCHEMA with values provided by the user.
"""
- # TODO validate the data can be used to set up a connection.
-
- # If your PyPI package is not built with async, pass your methods
- # to the executor:
- # await hass.async_add_executor_job(
- # your_validate_func, data["username"], data["password"]
- # )
-
- # hub = PlaceholderHub(data["host"])
-
- # if not await hub.authenticate(data["username"], data["password"]):
- # raise InvalidAuth
-
- # If you cannot connect:
- # throw CannotConnect
- # If the authentication is wrong:
- # InvalidAuth
# Return info that you want to store in the config entry.
return {"title": "Neerslag"}
@@ -53,7 +35,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Neerslag Sensor (Buienalarm / Buienradar)."""
VERSION = 1
- # TODO pick one of the available connection classes in homeassistant/config_entries.py
+
CONNECTION_CLASS = config_entries.CONN_CLASS_UNKNOWN
async def async_step_user(self, user_input=None):
@@ -72,11 +54,8 @@ async def async_step_user(self, user_input=None):
errors = {}
try:
- # info = await validate_input(self.hass, user_input)
title = "Neerslag App"
data = user_input
- # _LOGGER.info("Dit wordt nu uitgevoerd...........")
- # _LOGGER.info(data)
except CannotConnect:
errors["base"] = "cannot_connect"
@@ -106,10 +85,6 @@ def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
async def async_step_init(self, user_input=None):
- # _LOGGER.info("HIER>>>")
- # _LOGGER.info(self.config_entry.data.get("buienalarmLatitude"))
- # _LOGGER.info(self.config_entry.data.get("buienalarm"))
- # _LOGGER.info(self.config_entry.data.get("NeerslagSensorUseHAforLocation"))
testtest = vol.Schema({vol.Optional("buienalarm", default=self.config_entry.data.get("buienalarm")): bool,
vol.Optional("buienalarmLatitude", default=self.config_entry.data.get("buienalarmLatitude")): str,
vol.Optional("buienalarmLongitude", default=self.config_entry.data.get("buienalarmLongitude")): str,
@@ -119,15 +94,8 @@ async def async_step_init(self, user_input=None):
vol.Optional("NeerslagSensorUseHAforLocation", default=self.config_entry.data.get("NeerslagSensorUseHAforLocation")): bool
})
- # _LOGGER.info("----->>>>---------------")
- # _LOGGER.info(self.config_entry.options)
- # _LOGGER.info(self.config_entry.data)
- # _LOGGER.info("------<<<<--------------")
"""Manage the options."""
if user_input is not None:
- # _LOGGER.info(user_input)
- # _LOGGER.info("<><><><><><><><><><>")
- # self.config_entry.data = user_input
return self.async_create_entry(title="", data=user_input)
return self.async_show_form(
diff --git a/custom_components/neerslag/home-assistant-neerslag-card/neerslag-card.js b/custom_components/neerslag/home-assistant-neerslag-card/neerslag-card.js
index d1b221d..39e9f6d 100644
--- a/custom_components/neerslag/home-assistant-neerslag-card/neerslag-card.js
+++ b/custom_components/neerslag/home-assistant-neerslag-card/neerslag-card.js
@@ -4,21 +4,6 @@ import {
css
} from "https://unpkg.com/lit-element@3.1.2/lit-element.js?module";
-// class CombiCardEditor extends LitElement {
-
-// setConfig(config) {
-// this._config = config;
-// }
-
-// configChanged(newConfig) {
-// const event = new Event("config-changed", {
-// bubbles: true,
-// composed: true
-// });
-// event.detail = {config: newConfig};
-// this.dispatchEvent(event);
-// }
-// }
class CombiCard extends LitElement {
static get properties() {
@@ -36,10 +21,6 @@ class CombiCard extends LitElement {
}
}
- // static getConfigElement() {
- // return document.createElement("combi-card-editor");
- // }
-
static get styles() {
return css`
ha-card {
@@ -58,13 +39,10 @@ class CombiCard extends LitElement {
setConfig(config) {
- // console.log("setConfig");
if (!config.entity && !config.entities) {
throw new Error('You need to define an entity or a list of entities. See readme file for available entities (sensors)');
}
this._config = config;
-
- //default zoom waarde
this.zoomwaarde = 0.5;
}
@@ -100,19 +78,16 @@ class CombiCard extends LitElement {
let lang = this.getCurrentLanguage();
if(!this.vertaling[lang]){
- // language does not exist, default back to Dutch language
lang = 'nl'
}
let translatedText
- // key - translation found
if(this.vertaling[lang][key]){
translatedText = this.vertaling[lang][key];
} else {
if(lang != 'nl') {
lang = 'nl'
if(this.vertaling[lang][key]){
- // default back to dutch
translatedText = this.vertaling[lang][key];
} else {
translatedText = 'No translation text found'
@@ -131,9 +106,7 @@ class CombiCard extends LitElement {
return lang
}
-
render() {
-
if (!this._config || !this.hass) {
return html``;
}
@@ -208,30 +181,6 @@ class CombiCard extends LitElement {
`
}
- /*
- // Display "No Sensor Data card"
- if (!stateObj && !stateMultiObj) {
- if(this.hass.states[this._config.entity].attributes.data === "") {
- this.dontMakeGraph = true
- return html`
-
-
-
-
-
-
-
No sensor data available
-
-
-
-
- `
- }
- }
- */
-
- // console.log(this.hass.localize);
-
this.dontMakeGraph = false;
if(this.prepareChartDataSets().getChartsDataAlsArray()[0] === undefined) {
@@ -259,8 +208,6 @@ class CombiCard extends LitElement {
`;
-
-
}
// Display "Plot a graph card"
@@ -294,17 +241,10 @@ class CombiCard extends LitElement {
return;
}
- // changedProperties.forEach((oldValue, propName) => {
- // console.log(`${propName} changed. oldValue: ${oldValue}`);
- // });
this.makeGraph();
if (this.myChart.width === 0) {
- //console.log("firstUpdated: chart is niet zichtbaar!");
this.myChart.resize();
}
-
- //document.addEventListener('resize',this.test());
-
}
@@ -316,13 +256,11 @@ class CombiCard extends LitElement {
if (this.myChart) {
if (this.myChart.width === 0) {
- //console.log("updated(): chart is no visible!");
this.myChart.resize();
}
}
changedProperties.forEach((oldValue, propName) => {
-
// wanneer de kaart configuratie veranderd, zal _config veranderen
if (propName == "_config") {
this.makeGraph();
@@ -333,9 +271,7 @@ class CombiCard extends LitElement {
if (typeof oldValue != 'undefined') {
// when using single entity
if (this._config.entity) {
- //console.log(this._config.entity);
if (this.hass.states[this._config.entity].attributes.data !== oldValue.states[this._config.entity].attributes.data) {
- //console.log("data has changed, lets update")
this.updateGrafiek()
}
}
@@ -343,10 +279,7 @@ class CombiCard extends LitElement {
//when using multiple entities
if (this._config.entities) {
for (const entity of this._config.entities) {
- //console.log(entity)
if (this.hass.states[entity].attributes.data !== oldValue.states[entity].attributes.data) {
- // console.log("data has changed, lets update")
- // console.log(entity)
this.updateGrafiek()
}
}
@@ -363,7 +296,6 @@ class CombiCard extends LitElement {
return;
}
-
//https://stackoverflow.com/a/35663683/4181822
function hexify(color) {
var values = color
@@ -409,11 +341,8 @@ class CombiCard extends LitElement {
var primaryTextColor = convertToHexIfNeeded(style.getPropertyValue('--primary-text-color'));
var secondaryTextColor = convertToHexIfNeeded(style.getPropertyValue('--secondary-text-color'));
-
-
// verwijder de kaart
if(this.myChart) {
-
this.myChart=null;
this.renderRoot.getElementById("neerslagChart").remove();
let canvas = document.createElement('canvas');
@@ -428,7 +357,6 @@ class CombiCard extends LitElement {
if (this.shadowRoot) {
ctx = this.shadowRoot.getElementById("neerslagChart").getContext('2d');
}
- // this.myChart.options.transitions.active.animation.duration = 0
this.myChart = new Chart(ctx, {
type: 'line',
@@ -464,7 +392,6 @@ class CombiCard extends LitElement {
}
},
animation: false,
- // animation: { easing: 'easeOutCirc', duration: 500},
interaction: {
intersect: false,
mode: 'index',
@@ -480,7 +407,7 @@ class CombiCard extends LitElement {
display: false,
},
tooltip: {
- displayColors: false, //disable color boxes/legend
+ displayColors: false,
callbacks: {
label: function (context) {
@@ -505,7 +432,7 @@ class CombiCard extends LitElement {
type: 'line',
yMin: 5,
yMax: 5,
- borderColor: 'grey', //'rgb(255, 99, 132)',
+ borderColor: 'grey',
borderWidth: 1,
label: {
enabled: true,
@@ -521,7 +448,7 @@ class CombiCard extends LitElement {
type: 'line',
yMin: 2,
yMax: 2,
- borderColor: 'grey', //'rgb(255, 99, 132)',
+ borderColor: 'grey',
borderWidth: 1,
label: {
enabled: true,
@@ -537,7 +464,7 @@ class CombiCard extends LitElement {
type: 'line',
yMin: 0.4,
yMax: 0.4,
- borderColor: 'grey', //'rgb(255, 99, 132)',
+ borderColor: 'grey',
borderWidth: 1,
label: {
enabled: true,
@@ -565,7 +492,7 @@ class CombiCard extends LitElement {
ctx.moveTo(x, yAxis.top);
ctx.lineTo(x, yAxis.bottom);
ctx.lineWidth = 1;
- ctx.strokeStyle = 'rgba(190, 190, 190, 1)'; //rgba(0, 0, 255, 0.4)
+ ctx.strokeStyle = 'rgba(190, 190, 190, 1)';
ctx.stroke();
ctx.restore();
}
@@ -588,7 +515,6 @@ class CombiCard extends LitElement {
* @param {*} vlabel = defineer de label van de dataset (NAAM)
*/
generateDatasetObject(data, vlabel = "Regen") {
-
// entities in card moet object worden
// dan is het - entity:
// https://www.home-assistant.io/lovelace/entities/
@@ -603,62 +529,38 @@ class CombiCard extends LitElement {
return {
label: vlabel,
- data: data,
- // backgroundColor: [
- // 'rgba(89, 160, 238, 0.2)'
- // ],
- // borderColor: [
- // 'rgba(89, 160, 238, 1)'
- // ],
- // borderWidth: 2
+ data: data
}
}
- //sync buienradar en buienalarm
- //beide zijn objecten dus wanneer deze worden aangepast, dan wijzigt het ook meteen
+ /**
+ * Sync buienradar en buienalarm
+ * beide zijn objecten dus wanneer deze worden aangepast, dan wijzigt het ook meteen.
+ * Onderstaande functie werkt ook wanneer buienalarm in zijn dataset achterloopt
+ */
combineTwoArray(array1, array2) {
-
// fix - if only 1 entity is used
if(!array1 || !array2) {
return;
}
- //console.log(array1[0])
- //console.log(array2[0])
-
if (!array2[0] || !array1[0]) {
return;
}
- /**
- * wanneer buienalarm achterloopt in zijn geheel
- * werkt het onderstaande prima
- */
-
// fix dataset van array 2
for (const data of array1[0]) {
if (!array2[0].includes(data)) {
- // console.log("1 waarde niet gevonden: " + data);
-
let index = array1[0].indexOf(data)
- // console.log("1 waarde heeft index: " + index);
- // console.log(array2[0])
-
array2[0].splice(index, 0, array1[0][index])
array2[1].splice(index, 0, '0')
}
}
- // geen idee of dit gaat werken
// fix dataset van array 1
for (const data of array2[0]) {
if (!array1[0].includes(data)) {
- // console.log("2 waarde niet gevonden: " + data);
-
let index = array2[0].indexOf(data)
- // console.log("2 waarde heeft index: " + index);
- // console.log(array1[0])
-
array1[0].splice(index, 0, array2[0][index])
array1[1].splice(index, 0, '0')
}
@@ -707,8 +609,6 @@ class CombiCard extends LitElement {
}
prepareData(data, entity) {
-
- //console.log(this._config.entity);
if (!data || data.length === 0) {
return html``;
}
@@ -827,9 +727,6 @@ class CombiCard extends LitElement {
tijd.push(addZero(d.getHours()) + ":" + addZero(d.getMinutes()));
});
- // console.log(tijd)
- // console.log(rain);
-
let returnData = [];
returnData[0] = tijd;
returnData[1] = rain;
@@ -838,11 +735,6 @@ class CombiCard extends LitElement {
}
updateGrafiek() {
-
- let chartData
- let chartsDataAlsArray = []
- let chartDatasets = []
-
if (this.dontMakeGraph === true) {
console.log('updateGrafiek - dontMakeGraph')
return;
@@ -853,7 +745,6 @@ class CombiCard extends LitElement {
}
}
-// customElements.define("combi-card-editor", CombiCardEditor);
customElements.define('neerslag-card', CombiCard);
window.customCards = window.customCards || [];
diff --git a/custom_components/neerslag/sensor.py b/custom_components/neerslag/sensor.py
index 03cacd4..1a6479e 100644
--- a/custom_components/neerslag/sensor.py
+++ b/custom_components/neerslag/sensor.py
@@ -30,69 +30,9 @@
async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities):
"""Set up sensor entity."""
- # if config_entry.data.get("buienalarm") == True:
- # async_add_entities([NeerslagSensorBuienalarm(hass, config_entry)], update_before_add=True)
-
- # if config_entry.data.get("buienradar") == True:
- # async_add_entities([NeerslagSensorBuienradar(hass, config_entry)], update_before_add=True)
- # # async_add_entities([NeerslagSensor(hass, config_entry)])
-
- # entity_registry_obj = await hass.helpers.entity_registry.async_get_registry()
- # registry_entry = entity_registry_obj.async_get(config_entry.unique_id)
-
dev_reg = await hass.helpers.device_registry.async_get_registry()
ent_reg = await hass.helpers.entity_registry.async_get_registry()
- # dds = async_get_platforms(hass, "neerslag")
- # _LOGGER.info(len(dds))
- # async_reset
-
- # _LOGGER.info("----------->>>")
- # _LOGGER.info(dev_reg.devices)
- # _LOGGER.info(ent_reg.entities)
-
- # xx = "neerslag_DummyABC"
- # aa = ent_reg.async_get("sensor.neerslag_dummyabc")
-
- # _LOGGER.info("<<1aa<<<<<<<<<<<<<<<<<----------->>>")
- # _LOGGER.info(aa)
- # _LOGGER.info("<<>>")
-
- # bb = ent_reg.async_get_entity_id(domain='sensor', platform='neerslag', unique_id='neerslag-sensor-DummyABC')
- # _LOGGER.info(bb)
- # _LOGGER.info("<<>>")
-
- # cc = async_entries_for_config_entry(ent_reg, config_entry.entry_id)
- # _LOGGER.info(cc)
- # _LOGGER.info("<<>>")
-
- # ent_reg = hass.helpers.entity_registry.async_get_registry()
- # aaa = ent_reg.async_get_entity_id("neerslag", "sensor", self._unique_id)
-
- # _LOGGER.info(aaa)
-
- # _LOGGER.info(config_entry.entry_id)
- # _LOGGER.info(config_entry.unique_id)
-
- # rr = await config_entry.ConfigEntries.async_reload(config_entry.entry_id)
- # _LOGGER.info(rr)
-
- # async_add_entities([DummyABC(hass, config_entry)], update_before_add=True)
- # async_add_entities([DummyABC(hass, config_entry)], update_before_add=True)
-
- # if config_entry.data.get("buienalarm") == True:
- # _LOGGER.info("<><><><>----------------<><<><>")
- # async_add_entities([DummyABC(hass, config_entry, True)], update_before_add=True)
-
- # if config_entry.data.get("buienalarm") == False:
- # async_add_entities([DummyABC(hass, config_entry, False)], update_before_add=False)
-
- # if config_entry.data.get("buienradar") == True:
- # async_add_entities([DummyDEF(hass, config_entry, True)], update_before_add=True)
-
- # if config_entry.data.get("buienradar") == False:
- # async_add_entities([DummyDEF(hass, config_entry, False)], update_before_add=False)
-
if config_entry.data.get("buienalarm") == True:
async_add_entities([NeerslagSensorBuienalarm(hass, config_entry, True)], update_before_add=True)
@@ -105,15 +45,6 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry, asyn
if config_entry.data.get("buienradar") == False:
async_add_entities([NeerslagSensorBuienradar(hass, config_entry, False)], update_before_add=False)
- # async_add_entities([NeerslagSensor(hass, config_entry)])
-
- # device_registry = await hass.helpers.device_registry.async_get_registry()
- # device_registry.async_get_or_create(
- # config_entry_id=config_entry.entry_id,
- # default_manufacturer="dummy data",
- # default_model="dummy data",
- # default_name="dummy data")
-
class mijnBasis(Entity):
_enabled = None
@@ -122,35 +53,20 @@ class mijnBasis(Entity):
def __init__(self, hass: HomeAssistant, config_entry: ConfigEntry, enabled: bool):
_LOGGER.info("--<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>--->>>>>>>>>>>>>>>>>>>>>>>>")
- # self._enabled = enabled
- # config_entry.add_update_listener(self.mine_update_listener)
async def mine_update_listener(self, hass: HomeAssistant, config_entry: ConfigEntry, pp=None):
"""Handle options update."""
- # if(self._name == "neerslag_DummyABC"):
- # self._enabled = config_entry.data.get("buienalarm")
-
- # if(self._name == "neerslag_DummyDEF"):
- # self._enabled = config_entry.data.get("buienradar")
-
if(self._name == "neerslag_buienalarm_regen_data"):
self._enabled = config_entry.data.get("buienalarm")
if(self._name == "neerslag_buienradar_regen_data"):
self._enabled = config_entry.data.get("buienradar")
- # self._enabled = config_entry.data.get(enabled)
- # await hass.config_entries.async_remove(config_entry.entry_id)
- # rr = hass.config_entries.async_entries(DOMAIN)
- # hass.config_entries.async_update_entry(config_entry, data=config_entry.options)
- # await hass.config_entries.async_reload(config_entry.entry_id)
-
@property
def device_info(self):
return {
"identifiers": {
- # Serial numbers are unique identifiers within a specific domain
("neerslag", "neerslag-device")
},
"name": "Neerslag App",
@@ -183,34 +99,6 @@ async def async_update(self):
return True
-class DummyABC(mijnBasis):
- def __init__(self, hass: HomeAssistant, config_entry: ConfigEntry, enabled: bool):
- super().__init__(hass=hass, config_entry=config_entry, enabled=enabled)
- self._name = "neerslag_DummyABC"
- self._state = "working" # None
- self._attrs = ["data empty"]
- self._unique_id = "neerslag-sensor-DummyABC"
-
- self._enabled = enabled
- config_entry.add_update_listener(self.mine_update_listener)
-
-
-class DummyDEF(mijnBasis):
- def __init__(self, hass: HomeAssistant, config_entry: ConfigEntry, enabled: bool):
- super().__init__(hass=hass, config_entry=config_entry, enabled=enabled)
- self._name = "neerslag_DummyDEF"
- self._state = "working" # None
- self._attrs = ["data empty"]
- self._unique_id = "neerslag-sensor-DummyDEF"
-
- # _LOGGER.info(">>>>>>>>>>>>>>>>>>>>>>>>")
- # _LOGGER.info(config_entry.entry_id)
- # _LOGGER.info(config_entry.unique_id)
-
- self._enabled = enabled
- config_entry.add_update_listener(self.mine_update_listener)
-
-
class NeerslagSensorBuienalarm(mijnBasis):
def __init__(self, hass: HomeAssistant, config_entry: ConfigEntry, enabled: bool):
super().__init__(hass=hass, config_entry=config_entry, enabled=enabled)
@@ -230,11 +118,8 @@ def __init__(self, hass: HomeAssistant, config_entry: ConfigEntry, enabled: bool
self._lat = config_entry.data.get("buienalarmLatitude")
self._lon = config_entry.data.get("buienalarmLongitude")
- # format values, enforce 3 decimals
self._lat = f'{float(self._lat):.3f}'
self._lon = f'{float(self._lon):.3f}'
-
- # self._entity_picture = "https://www.buienalarm.nl/assets/img/social.png"
self._icon = "mdi:weather-cloudy"
@ property
@@ -246,7 +131,6 @@ def state_attributes(self):
if not len(self._attrs):
return
return self._attrs
- # return {"data": self._attrs}
async def async_update(self):
if(self._enabled == True):
@@ -256,7 +140,6 @@ async def async_update(self):
async def getBuienalarmData(self) -> str:
data = json.loads('{"data":""}')
- # return data
try:
timeout = aiohttp.ClientTimeout(total=5)
async with aiohttp.ClientSession() as session:
@@ -296,11 +179,8 @@ def __init__(self, hass: HomeAssistant, config_entry: ConfigEntry, enabled: bool
self._lat = config_entry.data.get("buienradarLatitude")
self._lon = config_entry.data.get("buienradarLongitude")
- # format values, enforce 2 decimals
self._lat = f'{float(self._lat):.2f}'
self._lon = f'{float(self._lon):.2f}'
-
- # self._entity_picture = "https://cdn.buienradar.nl/resources/images/br-logo-square.png"
self._icon = "mdi:weather-cloudy"
@ property
@@ -312,7 +192,6 @@ def state_attributes(self):
if not len(self._attrs):
return
return self._attrs
- # return {"data": self._attrs}
async def async_update(self):
if(self._enabled == True):
@@ -322,13 +201,10 @@ async def async_update(self):
async def getBuienradarData(self) -> str:
data = json.loads('{"data":""}')
- # return data
try:
timeout = aiohttp.ClientTimeout(total=5)
async with aiohttp.ClientSession() as session:
- # https://www.buienradar.nl/overbuienradar/gratis-weerdata
url = 'https://gps.buienradar.nl/getrr.php?lat=' + self._lat + '&lon=' + self._lon + '&c=' + str(rand.randint(0, 999999999999999))
- # _LOGGER.info(url)
async with session.get(url, timeout=timeout) as response:
html = await response.text()
dataRequest = html.replace('\r\n', ' ')