jeroenterheerdt / HAsmartirrigation

Smart Irrigation custom component for Home Assistant
https://jeroenterheerdt.github.io/HAsmartirrigation/
MIT License
363 stars 48 forks source link

[Bug] Error adding entities for domain sensor with platform smart_irrigation #49

Closed Dave-Bryant closed 3 years ago

Dave-Bryant commented 3 years ago

Describe the bug Error Log Messages: Error adding entities for domain sensor with platform smart_irrigation Error while setting up smart_irrigation platform for sensor

To Reproduce Steps to reproduce the behavior:

  1. Install Smart Irrigation
  2. Used my own sensors rather than OWM
  3. Restart HA

Expected behavior No error message. Not sure if is affecting the evapotranspiration calculation.

Screenshots image

Installed version Latest Integration on HA 2020.12

Additional context I have been using Smart Irrigation (a great product) with OWM. I changed to my own sensors a week ago. All the calculations seem to be happening, so it is possible I hadn't noticed this error. I am not sure if the error is affecting results.

jeroenterheerdt commented 3 years ago

It looks like it is still trying to parse your own sensor data as if it is OWM.

Dave-Bryant commented 3 years ago

I deleted the OWM and Smart Irrigation installation. I stopped the AppDaemon which references some of the entities. I then restarted and installed Smart Irrigation. The error message is still there.
1) Confirming that I leave a tick on the first page that says 'remove tick if you provide your own Evapotranspiration sensor'. 2) I notice that when you delete the SI integration the code remains in the custom components folder.

jeroenterheerdt commented 3 years ago

hmm, 2 is not supposed to happen. Can you please uninstall and remove the folder by hand, reboot and then reinstall?

Dave-Bryant commented 3 years ago

Error has gone. Thx for your help. I had not appreciated that an uninstall needs to happen at the HACS interface not just the HA Integration page.

Dave-Bryant commented 3 years ago

The error is back. It appears after an uninstall and reinstall it runs cleanly. After a 2nd restart the program goes looking for OWM data. I have looked at the program logic but it is a bit sophisticated for me. Any thoughts?

Dave-Bryant commented 3 years ago

I am using cytech/Home-Assistant-wundergroundpws to create my sensors. Could it be that the sensors aren’t being created in time for smart irrigation to pick them up. If so, how could I introduce a a delay for smart irrigation to run?

jeroenterheerdt commented 3 years ago

can you share your config? what are the settings you made?

bigwoof commented 3 years ago

Hi @jeroenterheerdt
I have a similar issue - I think that it is the same bug, here is the error log:

Logger: homeassistant.components.sensor
Source: custom_components/smart_irrigation/sensor.py:684
Integration: Sensor (documentation, issues)
First occurred: January 4, 2021, 8:46:07 AM (2 occurrences)
Last logged: January 4, 2021, 8:46:07 AM

Error adding entities for domain sensor with platform smart_irrigation
Error while setting up smart_irrigation platform for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 316, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 507, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 531, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 296, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 320, in _async_write_ha_state
    sstate = self.state
  File "/config/custom_components/smart_irrigation/sensor.py", line 551, in state
    self._state = self.update_state()
  File "/config/custom_components/smart_irrigation/sensor.py", line 510, in update_state
    self.evapotranspiration = self.get_evapotranspiration(data)
  File "/config/custom_components/smart_irrigation/sensor.py", line 684, in get_evapotranspiration
    pressure = data["pressure"]
KeyError: 'pressure'

and here is an extract of the config:

        {
            "entry_id": "0f170c17ae3adea1e16dae650350e11c",
            "version": 1,
            "domain": "smart_irrigation",
            "title": "Smart Irrigation",
            "data": {
                "number_of_sprinklers": 1.0,
                "flow": 21.59,
                "area": 50.0,
                "api_key": null,
                "reference_evapotranspiration": [
                    6.2,
                    5.7,
                    5.02,
                    4.34,
                    3.36,
                    3.1,
                    3.3,
                    4.0,
                    5.21,
                    5.78,
                    6.29,
                    6.47
                ],
                "name": "Smart Irrigation",
                "sources": {
                    "use_owm_precipitation": false,
                    "use_owm_temperature": false,
                    "use_owm_min_temperature": false,
                    "use_owm_max_temperature": false,
                    "use_owm_dewpoint": false,
                    "use_owm_pressure": false,
                    "use_owm_humidity": false,
                    "use_owm_windspeed": false,
                    "calculate_solar_radiation": false,
                    "calculate_ET_value": true
                },
                "sensors": {
                    "sensor_precipitation": "sensor.rain_daily",
                    "sensor_temperature": "sensor.weather_station_temperature",
                    "sensor_min_temperature": "sensor.daily_min_temp",
                    "sensor_max_temperature": "sensor.daily_max_temp",
                    "sensor_dewpoint": "sensor.weather_station_dewpoint",
                    "sensor_pressure": "sensor.pressure",
                    "sensor_humidity": "sensor.weather_station_humidity",
                    "sensor_windspeed": "sensor.weather_station_wind_speed",
                    "sensor_solar_radiation": "sensor.solar_radiation"
                }
            },
            "options": {},
            "system_options": {
                "disable_new_entities": false
            },
            "source": "user",
            "connection_class": "cloud_poll",
            "unique_id": "Smart Irrigation"
        },

I think that it is to do with the startup process as my weather station reports pressures and solar radiation every 5 min and doesn't return a value until the first mqtt post from the weather station. I suspect this error occurs since there is not value for pressure when it starts up.

jeroenterheerdt commented 3 years ago

ok, you can go into optional settings and set an initial update delay: see the readme: https://github.com/jeroenterheerdt/HAsmartirrigation#step-4-configuring-optional-settings

bigwoof commented 3 years ago

OK, thanks - I had it on 300s already which should be enough time, I bumped it up to 900s but it still gives errors (sometimes for t_min as well as pressure). This only seems to be an issue at startup as, from what I can tell it still provides working calulations.

Dave-Bryant commented 3 years ago

I have the same results i.e. had 300 increased to 600 second delay but the error remained. Here is my configuration as requested:

{ "entry_id": "337de23b856ecf0c5342924a0a996e89", "version": 1, "domain": "smart_irrigation", "title": "Smart Irrigation", "data": { "number_of_sprinklers": 23.0, "flow": 5.0, "area": 328.0, "api_key": null, "reference_evapotranspiration": [ 7.49, 5.64, 3.84, 2.54, 1.61, 1.19, 1.41, 1.8, 2.75, 3.55, 5.06, 8.1 ], "name": "Smart Irrigation", "sources": { "use_owm_precipitation": false, "use_owm_temperature": false, "use_owm_min_temperature": false, "use_owm_max_temperature": false, "use_owm_dewpoint": false, "use_owm_pressure": false, "use_owm_humidity": false, "use_owm_windspeed": false, "calculate_solar_radiation": false, "calculate_ET_value": true }, "sensors": { "sensor_precipitation": "sensor.wupws_preciptotal", "sensor_temperature": "sensor.wupws_temp", "sensor_min_temperature": "sensor.low_temperature_today", "sensor_max_temperature": "sensor.high_temperature_today", "sensor_dewpoint": "sensor.wupws_dewpt", "sensor_pressure": "sensor.wupws_pressure", "sensor_humidity": "sensor.wupws_humidity", "sensor_windspeed": "sensor.wupws_windspeed", "sensor_solar_radiation": "sensor.wupws_solarradiation" } }, "options": { "lead_time": 0, "maximum_duration": -1, "force_mode_duration": 0, "show_units": true, "auto_refresh": true, "auto_refresh_time": "23:00", "initial_update_delay": 300, "coastal": false, "estimate_solrad_from_temp": true }, "system_options": { "disable_new_entities": false }, "source": "user", "connection_class": "cloud_poll", "unique_id": "Smart Irrigation" }

jeroenterheerdt commented 3 years ago

For each of the sensors that give errors can you share a screenshot that shows values and attributes

Get Outlook for Androidhttps://aka.ms/ghei36


From: David Bryant notifications@github.com Sent: Monday, January 4, 2021 5:10:29 PM To: jeroenterheerdt/HAsmartirrigation HAsmartirrigation@noreply.github.com Cc: Jeroen ter Heerdt jeroen_ter_heerdt@hotmail.com; Mention mention@noreply.github.com Subject: Re: [jeroenterheerdt/HAsmartirrigation] [Bug] (#49)

I have the same results i.e. had 300 increased to 600 second delay but the error remained. Here is my configuration as requested:

{ "entry_id": "337de23b856ecf0c5342924a0a996e89", "version": 1, "domain": "smart_irrigation", "title": "Smart Irrigation", "data": { "number_of_sprinklers": 23.0, "flow": 5.0, "area": 328.0, "api_key": null, "reference_evapotranspiration": [ 7.49, 5.64, 3.84, 2.54, 1.61, 1.19, 1.41, 1.8, 2.75, 3.55, 5.06, 8.1 ], "name": "Smart Irrigation", "sources": { "use_owm_precipitation": false, "use_owm_temperature": false, "use_owm_min_temperature": false, "use_owm_max_temperature": false, "use_owm_dewpoint": false, "use_owm_pressure": false, "use_owm_humidity": false, "use_owm_windspeed": false, "calculate_solar_radiation": false, "calculate_ET_value": true }, "sensors": { "sensor_precipitation": "sensor.wupws_preciptotal", "sensor_temperature": "sensor.wupws_temp", "sensor_min_temperature": "sensor.low_temperature_today", "sensor_max_temperature": "sensor.high_temperature_today", "sensor_dewpoint": "sensor.wupws_dewpt", "sensor_pressure": "sensor.wupws_pressure", "sensor_humidity": "sensor.wupws_humidity", "sensor_windspeed": "sensor.wupws_windspeed", "sensor_solar_radiation": "sensor.wupws_solarradiation" } }, "options": { "lead_time": 0, "maximum_duration": -1, "force_mode_duration": 0, "show_units": true, "auto_refresh": true, "auto_refresh_time": "23:00", "initial_update_delay": 300, "coastal": false, "estimate_solrad_from_temp": true }, "system_options": { "disable_new_entities": false }, "source": "user", "connection_class": "cloud_poll", "unique_id": "Smart Irrigation" }

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fjeroenterheerdt%2FHAsmartirrigation%2Fissues%2F49%23issuecomment-754321632&data=04%7C01%7C%7C3ab5bc8e42eb4149c86508d8b116b2b6%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637454058329146659%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=6up9WiJH8J7XduLdPgfxTbgBPgz8ON9wSABvGHOr5ms%3D&reserved=0, or unsubscribehttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAB6PIPX7GWLRQ5U5QYCVECDSYJRILANCNFSM4U2AOADA&data=04%7C01%7C%7C3ab5bc8e42eb4149c86508d8b116b2b6%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637454058329156654%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=arDK6g4vrId2LbpGeUTbv0WSZNHpHzzgnyZGfMOZoSA%3D&reserved=0.

bigwoof commented 3 years ago

Here are some screenshots of the errors. effectively it is the hourly run time sensor that doesn't update on a Home assistant restart. Here is a history card showing the states after a reboot:

Capture

there are several reboots here which you can see when the netto precipitation goes to zero. The hourly run time is unavailable:

Capture1

but after a few about 5 minutes, it comes back again and appears to work normally:

Capture4

hope that helps to track down the issue. It looks like it is throwing the error when it can't pick up the values after the reboot but then all is good when it finally sees the appropriate sensors.

jeroenterheerdt commented 3 years ago

It looks like that for the pressure sensor the issue is with the sensor not reporting a value (notice there is a tiny gap in the graph at about the same time). That's why hourly adjusted run time fails to work. It will try again after the initial update delay however. I can make the code more resilient to these kind of errors, but in essence it is out of my control.

Dave-Bryant commented 3 years ago

Jeroen, I raised this issue initially as I was concerned it could affect results. It appears the results are correct, so I am comfortable to close this issue.

Dave-Bryant commented 3 years ago

It looks like the system assumes I am using OWM in the following routine when it checks for data. If I replace this test with 'if self.coordinator.api' the logic is the same but the error is removed. For your consideration.

def get_evapotranspiration(self, data): """Calculate Evantranspiration info from OWM data.""" if self.coordinator.api:

if data is not None:

        day_of_year = datetime.datetime.now().timetuple().tm_yday
        if "temp" in data:
            t_day = data["temp"]["day"]
            t_min = data["temp"]["min"]
            t_max = data["temp"]["max"]
        else:
            return 0.0
jeroenterheerdt commented 3 years ago

Thanks, which version of the component are you on?

Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: David Bryant @.> Sent: Thursday, August 5, 2021 6:21:13 PM To: jeroenterheerdt/HAsmartirrigation @.> Cc: Jeroen ter Heerdt @.>; Mention @.> Subject: Re: [jeroenterheerdt/HAsmartirrigation] [Bug] Error adding entities for domain sensor with platform smart_irrigation (#49)

It looks like the system assumes I am using OWM in the following routine when it checks for data. If I replace this test with 'if self.coordinator.api' the logic is the same but the error is removed. For your consideration.

def get_evapotranspiration(self, data): """Calculate Evantranspiration info from OWM data.""" if self.coordinator.api:

if data is not None:

day_of_year = datetime.datetime.now().timetuple().tm_yday if "temp" in data: t_day = data["temp"]["day"] t_min = data["temp"]["min"] t_max = data["temp"]["max"] else: return 0.0

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fjeroenterheerdt%2FHAsmartirrigation%2Fissues%2F49%23issuecomment-893932769&data=04%7C01%7C%7Ca4afa97eb0504b81b12908d958787b5b%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637638096757870877%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=OkqB6i1HxpN7moFrHOARrO5CHCcDlGXqMN0F3ez4ZCs%3D&reserved=0, or unsubscribehttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAB6PIPWF67DYOZV63K4PVCLT3M2ITANCNFSM4U2AOADA&data=04%7C01%7C%7Ca4afa97eb0504b81b12908d958787b5b%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637638096757880874%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=hihiQlZ4xqDz4C3rUbmFPbjPiLa3t2OulN6VphD%2FeQI%3D&reserved=0. Triage notifications on the go with GitHub Mobile for iOShttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fapps.apple.com%2Fapp%2Fapple-store%2Fid1477376905%3Fct%3Dnotification-email%26mt%3D8%26pt%3D524675&data=04%7C01%7C%7Ca4afa97eb0504b81b12908d958787b5b%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637638096757880874%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=vzhsWapHJztn2qgKX0GZTacQnZGoyNZ8lZhuHAytlLc%3D&reserved=0 or Androidhttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fplay.google.com%2Fstore%2Fapps%2Fdetails%3Fid%3Dcom.github.android%26utm_campaign%3Dnotification-email&data=04%7C01%7C%7Ca4afa97eb0504b81b12908d958787b5b%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637638096757890863%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=2BgCD3goKs0SKUPn6KMgcV8EBwSvbznemjbTeGFk6Vc%3D&reserved=0.

Dave-Bryant commented 3 years ago

"version": "0.0.69"

jeroenterheerdt commented 3 years ago

do you see any errors? or is everything working as expected? The component just uses the same data structure if the data came OWM or sensors or a mixture of both. So unless you are seeing errors I am confident this works as expected. If the comment let you to the conclusion that the component assumes you are using OWM then I can easily fix the comment. The code does not assume any of the sorts.

Dave-Bryant commented 3 years ago

Yes, the program assumes I am using OWM, when I am not. When the code gets to 'get_evapotranspiration(self, data)' it does a check just to confirm I am not using OWM. It does this check by querying 'if data is not None'. In my case the code must find some data and carries on as if I have OWM. When I replace the test of data with 'if self.coordinator.api:' the code does not proceed and I do not see the error 'Error adding entities for domain sensor with platform smart_irrigation'.

jeroenterheerdt commented 3 years ago

Can you please share the error log?

Dave-Bryant commented 3 years ago

Here is the log up to the error messages.

2021-08-13 15:14:32 INFO (MainThread) [custom_components.smart_irrigation]

Smart Irrigation Version: 0.0.73 If you have any issues with this you need to open an issue here: https://github.com/jeroenterheerdt/HASmartIrrigation/issues

2021-08-13 15:14:32 INFO (MainThread) [custom_components.smart_irrigation] Smart Irrigation sensors: {'sensor_windspeed': 'sensor.wind_speed_2', 'sensor_precipitation': 'sensor.daily_rain_rate_2', 'sensor_temperature': 'sensor.outdoor_temperature', 'sensor_min_temperature': 'sensor.low_temperature_today', 'sensor_max_temperature': 'sensor.high_temperature_today', 'sensor_dewpoint': 'sensor.dewpoint', 'sensor_pressure': 'sensor.relative_pressure', 'sensor_humidity': 'sensor.humidity'} 2021-08-13 15:14:32 INFO (MainThread) [custom_components.smart_irrigation] Auto refresh is enabled. Scheduling for 23:00. 2021-08-13 15:14:32 INFO (MainThread) [custom_components.smart_irrigation] Initial update scheduled for 2021-08-13 15:19:32.337681+10:00 2021-08-13 15:14:32 INFO (MainThread) [custom_components.smart_irrigation] Updating Smart Irrigation Data 2021-08-13 15:14:32 INFO (MainThread) [custom_components.auto_backup.config_flow] Importing config entry from configuration.yaml 2021-08-13 15:14:32 INFO (MainThread) [hass_nabucasa.iot] Connected 2021-08-13 15:14:32 INFO (MainThread) [snitun.utils.aiohttp_client] AioHTTP snitun client started on 127.0.0.1:53845 2021-08-13 15:14:32 INFO (MainThread) [homeassistant.setup] Setup of domain media_source took 5.4 seconds 2021-08-13 15:14:32 INFO (MainThread) [homeassistant.setup] Setup of domain system_health took 5.4 seconds 2021-08-13 15:14:32 INFO (SyncWorker_4) [homeassistant.loader] Loaded google_translate from homeassistant.components.google_translate 2021-08-13 15:14:32 INFO (MainThread) [homeassistant.setup] Setting up tplink 2021-08-13 15:14:32 INFO (MainThread) [homeassistant.setup] Setup of domain tplink took 0.0 seconds 2021-08-13 15:14:32 INFO (MainThread) [homeassistant.setup] Setting up network 2021-08-13 15:14:32 INFO (MainThread) [homeassistant.setup] Setup of domain scene took 5.0 seconds 2021-08-13 15:14:32 INFO (MainThread) [homeassistant.setup] Setting up hacs 2021-08-13 15:14:32 INFO (MainThread) [homeassistant.setup] Setup of domain hacs took 0.0 seconds 2021-08-13 15:14:33 INFO (MainThread) [homeassistant.setup] Setting up smartthings 2021-08-13 15:14:33 INFO (MainThread) [homeassistant.setup] Setting up energy 2021-08-13 15:14:33 INFO (MainThread) [homeassistant.setup] Setup of domain energy took 0.0 seconds 2021-08-13 15:14:33 INFO (MainThread) [homeassistant.setup] Setting up script 2021-08-13 15:14:33 INFO (MainThread) [homeassistant.setup] Setup of domain logbook took 1.2 seconds 2021-08-13 15:14:33 INFO (MainThread) [homeassistant.setup] Setting up camera 2021-08-13 15:14:33 INFO (MainThread) [homeassistant.setup] Setup of domain ffmpeg took 6.2 seconds 2021-08-13 15:14:33 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up binary_sensor.tasmota 2021-08-13 15:14:33 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.tasmota 2021-08-13 15:14:33 INFO (MainThread) [homeassistant.components.switch] Setting up switch.tasmota 2021-08-13 15:14:33 INFO (MainThread) [homeassistant.setup] Setup of domain tag took 1.2 seconds 2021-08-13 15:14:33 INFO (SyncWorker_4) [homeassistant.loader] Loaded stt from homeassistant.components.stt 2021-08-13 15:14:33 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.smart_irrigation 2021-08-13 15:14:33 INFO (MainThread) [custom_components.auto_backup] Setting up Auto Backup config entry 67c8c53062882439c791c979faa4d44d 2021-08-13 15:14:33 INFO (SyncWorker_1) [homeassistant.loader] Loaded fan from homeassistant.components.fan 2021-08-13 15:14:33 INFO (SyncWorker_4) [homeassistant.loader] Loaded cover from homeassistant.components.cover 2021-08-13 15:14:33 INFO (SyncWorker_2) [homeassistant.loader] Loaded light from homeassistant.components.light 2021-08-13 15:14:33 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up binary_sensor.cloud 2021-08-13 15:14:33 INFO (MainThread) [custom_components.smart_irrigation.sensor] sensor init for current_adjusted_run_time. bucket_delta=0 2021-08-13 15:14:33 INFO (MainThread) [custom_components.smart_irrigation.sensor] sensor init for adjusted_run_time. bucket=0 2021-08-13 15:14:33 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.energy 2021-08-13 15:14:33 INFO (MainThread) [homeassistant.setup] Setting up stt 2021-08-13 15:14:33 INFO (MainThread) [homeassistant.setup] Setup of domain stt took 0.0 seconds 2021-08-13 15:14:33 INFO (MainThread) [homeassistant.setup] Setup of domain input_select took 6.6 seconds 2021-08-13 15:14:33 INFO (MainThread) [homeassistant.setup] Setup of domain network took 1.2 seconds 2021-08-13 15:14:33 INFO (MainThread) [homeassistant.setup] Setting up fan 2021-08-13 15:14:33 INFO (MainThread) [homeassistant.setup] Setup of domain fan took 0.0 seconds 2021-08-13 15:14:33 INFO (MainThread) [homeassistant.setup] Setting up cover 2021-08-13 15:14:33 INFO (MainThread) [homeassistant.setup] Setup of domain cover took 0.0 seconds 2021-08-13 15:14:33 INFO (MainThread) [homeassistant.setup] Setting up light 2021-08-13 15:14:34 INFO (MainThread) [homeassistant.setup] Setup of domain counter took 6.5 seconds 2021-08-13 15:14:34 INFO (MainThread) [homeassistant.setup] Setup of domain timer took 6.5 seconds 2021-08-13 15:14:34 INFO (MainThread) [homeassistant.setup] Setup of domain input_datetime took 2.1 seconds 2021-08-13 15:14:34 INFO (MainThread) [homeassistant.setup] Setup of domain smartthings took 1.0 seconds 2021-08-13 15:14:34 INFO (MainThread) [homeassistant.setup] Setup of domain camera took 1.0 seconds 2021-08-13 15:14:34 INFO (MainThread) [homeassistant.setup] Setup of domain script took 1.1 seconds 2021-08-13 15:14:34 INFO (MainThread) [homeassistant.components.fan] Setting up fan.tasmota 2021-08-13 15:14:34 INFO (MainThread) [homeassistant.components.cover] Setting up cover.tasmota 2021-08-13 15:14:34 INFO (MainThread) [homeassistant.setup] Setup of domain light took 0.4 seconds 2021-08-13 15:14:34 INFO (MainThread) [homeassistant.setup] Setup of domain group took 2.4 seconds 2021-08-13 15:14:34 INFO (MainThread) [homeassistant.components.camera] Setting up camera.foscam 2021-08-13 15:14:34 INFO (MainThread) [homeassistant.components.camera] Setting up camera.foscam 2021-08-13 15:14:34 INFO (MainThread) [custom_components.smart_irrigation] registering: type: Base Schedule Index, entity: sensor.smart_irrigation_base_schedule_index 2021-08-13 15:14:34 INFO (MainThread) [custom_components.smart_irrigation.sensor] async_added_t_hass type: Base Schedule Index state: 1386.2, attributes: {'number_of_sprinklers': 23.0, 'flow': '5.0', 'throughput': '115.0', 'reference_evapotranspiration': '[7.49, 5.64, 3.84, 2.54, 1.61, 1.19, 1.41, 1.8, 2.75, 3.55, 5.06, 8.1]', 'peak_evapotranspiration': '8.1', 'area': '328.0', 'precipitation_rate': '21.04', 'base_schedule_index_minutes': 23.1, 'auto_refresh': True, 'auto_refresh_time': '23:00', 'initial_update_delay': 300, 'coastal': False, 'estimate_solrad_from_temp': True, 'unit_of_measurement': 's', 'friendly_name': 'Base Schedule Index', 'icon': 'mdi:sprinkler'} 2021-08-13 15:14:34 INFO (MainThread) [custom_components.smart_irrigation.sensor] update_state for type: Base Schedule Index 2021-08-13 15:14:34 INFO (MainThread) [custom_components.smart_irrigation.sensor] update_state for type: Base Schedule Index 2021-08-13 15:14:34 INFO (MainThread) [custom_components.smart_irrigation] registering: type: Hourly Adjusted Run Time, entity: sensor.smart_irrigation_hourly_adjusted_run_time 2021-08-13 15:14:34 INFO (MainThread) [custom_components.smart_irrigation.sensor] async_added_t_hass type: Hourly Adjusted Run Time state: 0, attributes: {'rain': '0.0', 'snow': '0.0', 'precipitation': '0.0', 'evapotranspiration': '0.0', 'netto_precipitation': '0.0', 'water_budget': 0.0, 'adjusted_run_time_minutes': 0.0, 'unit_of_measurement': 's', 'friendly_name': 'Hourly Adjusted Run Time', 'icon': 'mdi:sprinkler'} 2021-08-13 15:14:34 INFO (MainThread) [custom_components.smart_irrigation.sensor] async_added_t_hass type: Hourly Adjusted Run Time, attribute: evapotranspiration, attribute_value: 0.0, numeric_part: 0.0, show_units: False, a_val was str or contained ' ': False 2021-08-13 15:14:34 INFO (MainThread) [custom_components.smart_irrigation.sensor] async_added_t_hass type: Hourly Adjusted Run Time, attribute: netto_precipitation, attribute_value: 0.0, numeric_part: 0.0, show_units: False, a_val was str or contained ' ': False 2021-08-13 15:14:34 INFO (MainThread) [custom_components.smart_irrigation.sensor] async_added_to_hass restoring state, setting netto precipitation / bucket_delta to: 0.0 2021-08-13 15:14:34 INFO (MainThread) [custom_components.smart_irrigation.sensor] async_added_t_hass type: Hourly Adjusted Run Time, attribute: precipitation, attribute_value: 0.0, numeric_part: 0.0, show_units: False, a_val was str or contained ' ': False 2021-08-13 15:14:34 INFO (MainThread) [custom_components.smart_irrigation.sensor] async_added_t_hass type: Hourly Adjusted Run Time, attribute: rain, attribute_value: 0.0, numeric_part: 0.0, show_units: False, a_val was str or contained ' ': False 2021-08-13 15:14:34 INFO (MainThread) [custom_components.smart_irrigation.sensor] async_added_t_hass type: Hourly Adjusted Run Time, attribute: snow, attribute_value: 0.0, numeric_part: 0.0, show_units: False, a_val was str or contained ' ': False 2021-08-13 15:14:34 INFO (MainThread) [custom_components.smart_irrigation.sensor] async_added_t_hass type: Hourly Adjusted Run Time, attribute: water_budget, attribute_value: 0.0, numeric_part: 0.0, show_units: False, a_val was str or contained ' ': False 2021-08-13 15:14:34 INFO (MainThread) [custom_components.smart_irrigation.sensor] async_added_t_hass type: Hourly Adjusted Run Time, attribute: adjusted_run_time_minutes, attribute_value: 0.0, numeric_part: 0.0, show_units: False, a_val was str or contained ' ': False 2021-08-13 15:14:34 INFO (MainThread) [custom_components.smart_irrigation.sensor] update_state for type: Hourly Adjusted Run Time 2021-08-13 15:14:34 INFO (MainThread) [custom_components.smart_irrigation.sensor] update_state USING A SENSOR for instance Smart_Irrigation, type: Hourly Adjusted Run Time, sensor: sensor_windspeed, entity: sensor.wind_speed_2, sensor_state: None 2021-08-13 15:14:34 INFO (MainThread) [custom_components.smart_irrigation.sensor] update_state USING A SENSOR for instance Smart_Irrigation, type: Hourly Adjusted Run Time, sensor: sensor_precipitation, entity: sensor.daily_rain_rate_2, sensor_state: None 2021-08-13 15:14:34 INFO (MainThread) [custom_components.smart_irrigation.sensor] update_state USING A SENSOR for instance Smart_Irrigation, type: Hourly Adjusted Run Time, sensor: sensor_temperature, entity: sensor.outdoor_temperature, sensor_state: None 2021-08-13 15:14:34 INFO (MainThread) [custom_components.smart_irrigation.sensor] update_state USING A SENSOR for instance Smart_Irrigation, type: Hourly Adjusted Run Time, sensor: sensor_min_temperature, entity: sensor.low_temperature_today, sensor_state: <state sensor.low_temperature_today=unknown; unit_of_measurement=°C, friendly_name=Low Temperature Today @ 2021-08-13T15:14:25.530598+10:00> 2021-08-13 15:14:34 INFO (MainThread) [custom_components.smart_irrigation.sensor] update_state USING A SENSOR for instance Smart_Irrigation, type: Hourly Adjusted Run Time, sensor: sensor_max_temperature, entity: sensor.high_temperature_today, sensor_state: <state sensor.high_temperature_today=unknown; unit_of_measurement=°C, friendly_name=High Temperature Today @ 2021-08-13T15:14:25.530097+10:00> 2021-08-13 15:14:34 INFO (MainThread) [custom_components.smart_irrigation.sensor] update_state USING A SENSOR for instance Smart_Irrigation, type: Hourly Adjusted Run Time, sensor: sensor_dewpoint, entity: sensor.dewpoint, sensor_state: None 2021-08-13 15:14:34 INFO (MainThread) [custom_components.smart_irrigation.sensor] update_state USING A SENSOR for instance Smart_Irrigation, type: Hourly Adjusted Run Time, sensor: sensor_pressure, entity: sensor.relative_pressure, sensor_state: None 2021-08-13 15:14:34 INFO (MainThread) [custom_components.smart_irrigation.sensor] update_state USING A SENSOR for instance Smart_Irrigation, type: Hourly Adjusted Run Time, sensor: sensor_humidity, entity: sensor.humidity, sensor_state: None 2021-08-13 15:14:34 INFO (MainThread) [custom_components.smart_irrigation.sensor] rain: 0.0, snow: 0.0 2021-08-13 15:14:34 INFO (MainThread) [custom_components.smart_irrigation] registering: type: Daily Adjusted Run Time, entity: sensor.smart_irrigation_daily_adjusted_run_time 2021-08-13 15:14:34 INFO (MainThread) [custom_components.smart_irrigation.sensor] async_added_t_hass type: Daily Adjusted Run Time state: 0, attributes: {'water_budget': 0.0, 'bucket': '313.83', 'lead_time': 0, 'maximum_duration': -1, 'adjusted_run_time_minutes': 0.0, 'force_mode_duration': 0, 'force_mode_enabled': False, 'unit_of_measurement': 's', 'icon': 'mdi:sprinkler', 'friendly_name': 'Daily Adjusted Run Time'} 2021-08-13 15:14:34 INFO (MainThread) [custom_components.smart_irrigation.sensor] async_added_t_hass type: Daily Adjusted Run Time, attribute: water_budget, attribute_value: 0.0, numeric_part: 0.0, show_units: False, a_val was str or contained ' ': False 2021-08-13 15:14:34 INFO (MainThread) [custom_components.smart_irrigation.sensor] async_added_t_hass type: Daily Adjusted Run Time, attribute: bucket, attribute_value: 313.83, numeric_part: 313.83, show_units: False, a_val was str or contained ' ': False 2021-08-13 15:14:34 INFO (MainThread) [custom_components.smart_irrigation.sensor] async_added_to_hass restoring state, settting bucket to: 313.83 2021-08-13 15:14:34 INFO (MainThread) [custom_components.smart_irrigation.sensor] async_added_t_hass type: Daily Adjusted Run Time, attribute: adjusted_run_time_minutes, attribute_value: 0.0, numeric_part: 0.0, show_units: False, a_val was str or contained ' ': False 2021-08-13 15:14:34 INFO (MainThread) [custom_components.smart_irrigation.sensor] update_state for type: Daily Adjusted Run Time 2021-08-13 15:14:34 INFO (MainThread) [custom_components.smart_irrigation.sensor] Calculated water_budget = 0 and adjusted_run_time: 0 for type: Daily Adjusted Run Time. Bucket value was: 313.83, and base schedule index is: 1386.1565217391305, force mode is: False, force mode duration is: 0, lead_time is: 0, maximum_duration: -1, change percentage: 1.0, type: Daily Adjusted Run Time 2021-08-13 15:14:34 INFO (MainThread) [custom_components.smart_irrigation.sensor] calculating wb and art for daily adjusted run time, result: {'wb': 0, 'art': 0} 2021-08-13 15:14:34 INFO (MainThread) [custom_components.smart_irrigation.sensor] update_state for type: Daily Adjusted Run Time 2021-08-13 15:14:34 INFO (MainThread) [custom_components.smart_irrigation.sensor] Calculated water_budget = 0 and adjusted_run_time: 0 for type: Daily Adjusted Run Time. Bucket value was: 313.83, and base schedule index is: 1386.1565217391305, force mode is: False, force mode duration is: 0, lead_time is: 0, maximum_duration: -1, change percentage: 1.0, type: Daily Adjusted Run Time 2021-08-13 15:14:34 INFO (MainThread) [custom_components.smart_irrigation.sensor] calculating wb and art for daily adjusted run time, result: {'wb': 0, 'art': 0} 2021-08-13 15:14:34 INFO (MainThread) [homeassistant.components.light] Setting up light.tasmota 2021-08-13 15:14:34 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.speedtestdotnet 2021-08-13 15:14:34 INFO (MainThread) [custom_components.hacs]

HACS (Home Assistant Community Store) Version: 1.13.2 This is a custom integration If you have any issues with this you need to open an issue here: https://github.com/hacs/integration/issues

2021-08-13 15:14:34 INFO (MainThread) [custom_components.hacs] Setup task HacsSetupTask.WEBSOCKET 2021-08-13 15:14:34 INFO (MainThread) [custom_components.hacs] Setup task HacsSetupTask.FRONTEND 2021-08-13 15:14:34 INFO (MainThread) [custom_components.hacs] LovelaceMode.STORAGE mode, cache for /hacsfiles/: True 2021-08-13 15:14:34 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.auto_backup 2021-08-13 15:14:34 ERROR (MainThread) [homeassistant.components.sensor] Error adding entities for domain sensor with platform smart_irrigation Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 382, in async_add_entities await asyncio.gather(tasks) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 587, in _async_add_entity await entity.add_to_platform_finish() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 711, in add_to_platform_finish self.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 464, in async_write_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 498, in _async_write_ha_state state = self._stringify_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 470, in _stringify_state state = self.state File "/config/custom_components/smart_irrigation/sensor.py", line 557, in state self._state = self.update_state() File "/config/custom_components/smart_irrigation/sensor.py", line 516, in update_state self.evapotranspiration = self.get_evapotranspiration(data) File "/config/custom_components/smart_irrigation/sensor.py", line 684, in get_evapotranspiration t_day = data["temp"]["day"] KeyError: 'day' 2021-08-13 15:14:35 INFO (MainThread) [homeassistant.setup] Setting up automation 2021-08-13 15:14:36 INFO (MainThread) [custom_components.hacs] Setup task HacsSetupTask.CATEGORIES 2021-08-13 15:14:36 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up smart_irrigation platform for sensor Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 257, in _async_setup_platform await asyncio.gather(pending) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 382, in async_add_entities await asyncio.gather(*tasks) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 587, in _async_add_entity await entity.add_to_platform_finish() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 711, in add_to_platform_finish self.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 464, in async_write_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 498, in _async_write_ha_state state = self._stringify_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 470, in _stringify_state state = self.state File "/config/custom_components/smart_irrigation/sensor.py", line 557, in state self._state = self.update_state() File "/config/custom_components/smart_irrigation/sensor.py", line 516, in update_state self.evapotranspiration = self.get_evapotranspiration(data) File "/config/custom_components/smart_irrigation/sensor.py", line 684, in get_evapotranspiration t_day = data["temp"]["day"] KeyError: 'day' 2021-08-13 15:14:36 INFO (MainThread) [homeassistant.setup] Setup of domain zone took 4.0 seconds 2021-08-13 15:14:36 INFO (MainThread) [custom_components.hacs] HACS is enabled

jeroenterheerdt commented 3 years ago

ok, so let me explain again: we use the same data structure for the OWM and the sensor data. If you have only sensors that data is put into the OWM data structure so we don't have to handle it differently. The function that fails now is just parsing the data, and does not know (and does not have to know) if the data come from OWM or from sensors or a mixture. Changing the if statement as you did does not do the right thing as it will disable the calculation of the ET value all together. What is the real issue here is that the day temperature is not included in the data structure provided as input into the get_evotranspiration function. I am seeing a couple of interesting things in the logs:

Dave-Bryant commented 3 years ago

The initial update delay is set to 300s. I have confirmed the day temperature is available (it displays on Lovelace), however the max & min temperatures may not be available initially as they are calculated by a template on the day temperature.
I appreciate your efforts and feedback. This is a great app and works well for me. I will close this issue.

jeroenterheerdt commented 3 years ago

Thanks for the kind words. You might want to check out Daily Sensor, a component I made as well. Link is in the readme. It is built to give you the max and min and works fine with this component.

Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: David Bryant @.> Sent: Monday, August 16, 2021 5:29:22 PM To: jeroenterheerdt/HAsmartirrigation @.> Cc: Jeroen ter Heerdt @.>; Mention @.> Subject: Re: [jeroenterheerdt/HAsmartirrigation] [Bug] Error adding entities for domain sensor with platform smart_irrigation (#49)

The initial update delay is set to 300s. I have confirmed the day temperature is available (it displays on Lovelace), however the max & min temperatures may not be available initially as they are calculated by a template on the day temperature. I appreciate your efforts and feedback. This is a great app and works well for me. I will close this issue.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fjeroenterheerdt%2FHAsmartirrigation%2Fissues%2F49%23issuecomment-899905223&data=04%7C01%7C%7C3a73798edae046eff96008d961160f9c%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637647569644544213%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=fQInom0fbg4nza40jXsyvCKb9Lj1fEXSVDqDPrP9pxs%3D&reserved=0, or unsubscribehttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAB6PIPQIZGVQHIWDUFSWZ7TT5GUOFANCNFSM4U2AOADA&data=04%7C01%7C%7C3a73798edae046eff96008d961160f9c%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637647569644544213%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=ECbklBN%2FoSS1pB067XJ7igbzEsO4Qr0xbRVxvboAok4%3D&reserved=0. Triage notifications on the go with GitHub Mobile for iOShttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fapps.apple.com%2Fapp%2Fapple-store%2Fid1477376905%3Fct%3Dnotification-email%26mt%3D8%26pt%3D524675&data=04%7C01%7C%7C3a73798edae046eff96008d961160f9c%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637647569644554210%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=q6vr6kVkl4ScEObEM8LnXfbl%2FUZY7ImL2fxVeLZTQOY%3D&reserved=0 or Androidhttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fplay.google.com%2Fstore%2Fapps%2Fdetails%3Fid%3Dcom.github.android%26utm_campaign%3Dnotification-email&data=04%7C01%7C%7C3a73798edae046eff96008d961160f9c%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637647569644554210%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=FvT42gwmteVtU6%2FvyvTrueWoA8%2B%2BCzBwRB0uRyV0Ewo%3D&reserved=0.