jeroenterheerdt / hasmartirrigation Goto Github PK
View Code? Open in Web Editor NEWSmart Irrigation custom component for Home Assistant
License: MIT License
Smart Irrigation custom component for Home Assistant
License: MIT License
Describe the bug
yesterday I updated to 0.0.60 ... and noticed this error in log ... just after HA restart
2020-07-05 23:36:18 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 186, in _async_setup_platform
await asyncio.gather(*pending)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 292, in async_add_entities
await asyncio.gather(*tasks)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 451, in _async_add_entity
entity.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 290, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 317, in _async_write_ha_state
attr.update(self.device_state_attributes or {})
File "/config/custom_components/smart_irrigation/sensor.py", line 554, in device_state_attributes
self.coordinator.show_units,
File "/config/custom_components/smart_irrigation/helpers.py", line 82, in show_mm_or_inch
retval = f"{round(value,2)}"
TypeError: type list doesn't define __round__ method
During intergation setup we receive the error: Open Weather API key incorrect
Within the HA log we see:
2020-05-20 00:01:21 ERROR (MainThread) [custom_components.smart_irrigation.config_flow] Cannot talk to OWM API, check API key.
2020-05-20 00:03:29 WARNING (MainThread) [homeassistant.util.async_] Detected I/O inside the event loop. This is causing stability issues. Please report issue to the custom component author for smart_irrigation doing I/O at custom_components/smart_irrigation/OWMClient.py, line 24: r = requests.get(self.url)
2020-05-20 00:03:29 ERROR (MainThread) [custom_components.smart_irrigation.OWMClient] Failed to get OWM URL {"cod":401, "message": "Invalid API key. Please see http://openweathermap.org/faq#error401 for more info."}
2020-05-20 00:03:29 ERROR (MainThread) [custom_components.smart_irrigation.OWMClient] Cannot talk to OWM API, check API key.
2020-05-20 00:03:29 ERROR (MainThread) [custom_components.smart_irrigation.config_flow] Cannot talk to OWM API, check API key.
This is a new OWM account with validated emailaddress, created a new API Key named it HASS.IO
make number_of_sprinklers, flow, area configurable using options flow as well.
Where would i get a Evapotranspiration sensor to use in this project?
When starting up HASS from version 2021.3.0 and up we see a warning message:
2021-03-06 17:33:48 WARNING (MainThread) [homeassistant.loader] No 'version' key in the manifest file for custom integration 'smart_irrigation'. This will not be allowed in a future version of Home Assistant. Please report this to the maintainer of 'smart_irrigation'
So to have smart_irrigation working with 2021.4+ this needs to be added/solved.
Is your feature request related to a problem? Please describe.
The best time to use your sprinklers is right before sunrise, apparently that is best for your plants, and worst for any weeds, while it being still night is obviously better with regard to evaporation.
Describe the solution you'd like
Event thrown when you should start watering, the amount of time before sunrise that it needs to water.
Describe alternatives you've considered
Complex automations with sunset offset etc. but this code should have all the knowledge on what time to start, so why not use the eventing engine to let a automation pick it up.
Additional context
More complex is that I have three sprinklers for my grass, so currently have them scheduled one after another, which makes it a bit more complex, but that is not necessary for this.
Describe the bug
A clear and concise description of what the bug is.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
Add screenshots of the entities and their attributes.
Installed version
Which version of the component are you running?
Additional context
Add any other context about the problem here.
Describe the bug
After downloading the custom component from HACS, I cannot find the Smart Irrigation in Configuration -> Integrations.
When upgrading to v0.0.31 suddenly the daily runtime was multiplied by 100. As you changed percentage i opened integration options, saw 100 as percentage and did a save. After that the daily runtime was restored. I rebooted HA again to make sure it is not a startup bug but it wasn't: after restart daily runtime values was OK.
But my irrigation automation is not running anymore. It fails with error:
2020-06-04 03:00:00 ERROR (MainThread) [homeassistant.components.automation] Automatische beregening: Error rendering Automatische beregening delay template: expected int for dictionary value @ data['seconds']
Here you see the multiply bug happened after upgrade to v0.0.31 and the current values which look good:
Code for delay which worked without issues until now:
Describe the bug
A clear and concise description of what the bug is.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
Add screenshots of the entities and their attributes.
Installed version
Which version of the component are you running?
Additional context
Add any other context about the problem here.
I added the integration from scratch; got the following errors:
Logger: custom_components.smart_irrigation.sensor
Source: custom_components/smart_irrigation/sensor.py:170
smart_irrigation.do_calcs_hourly_adjusted_run_time
smart_irrigation.do_calcs_daily_adjusted_run_time
Is your feature request related to a problem? Please describe.
Sometimes the smart irrigation will run just before it starts raining (or even while it is raining). This all depends on the time when the daily volume is calculated and when the automation is triggered obviously.
I guess the rain is still counted towards the next bucket calculation, but anyway, this seems like a waste of water to me.
Moreoever, this could be potentially damaging in case of very intense rain/storms, as the ground will already be "saturated" due to the automatic irrigation, which can lead to quicker flooding, etc.
Describe the solution you'd like
Add an option that allows to delay the irrigation in case of forecasted (heavy) precipitation to avoid unnecessary watering/flooding. For instance:
An other way to do this check would also to try to "predict" the next day bucket directly based on temperature and precipitation forecast. If the next day's bucket is enough to compensate day N and day N+1 water needs, then skip irrigation.
Describe alternatives you've considered
An alternative would be to add a conditional statement in the automation to check if any rain is forecasted or compare the scheduled bucket with the next day precipitation.
Calling service "smart_irrigation.calculate_daily_adjusted_run_time" several times causes to accumulate seconds several times.
Because of it, there should be a possibility to disable automatic calculation at 23:00,
so user could calculate once time once - just before starting sprinklers.
Otherwise - user will calculate time on its own, and additionally it will be done at 23:00.
This may cause exceeding optimal sprinkling time by value accumulation.
Describe the bug
We have seen situations where suddenly the daily adjusted run time bucket is jumping up for no good reason. Please let us know if you see this as well and under what circumstances.
After selecting Smart Irrigation from Home Assistant Integration list the windows do not have labels
The Configuration Windows hasn't any labels
Home Assistant on a Docker (OpenMediaVault Nas)
Home Assistant 0.108.6
arch | x86_64 |
---|---|
dev | false |
docker | true |
hassio | false |
os_name | Linux |
os_version | 4.19.0-0.bpo.8-amd64 |
python_version | 3.7.7 |
timezone | Europe/Rome |
version | 0.108.6 |
virtualenv | false |
Hi, I have problem with that:
Logger: homeassistant.util.async_
Source: util/async_.py:120
First occurred: 18:18:04 (2 occurrences)
Last logged: 18:23:09
Detected I/O inside the event loop. This is causing stability issues. Please report issue to the custom component author for smart_irrigation doing I/O at custom_components/smart_irrigation/OWMClient.py, line 24: r = requests.get(self.url)
Hey. It would be nice to add some kind of support for Hozelock smart valves.
The problem with them is that they dont necessarily allow manual opening and closing of valves. Instead there's one preset length of irrigation which can happen once per day at set time or twice at sunrise and sunset and this irrigation time can be adjusted daily (using a HA script) by round numbers like 25%, 50%, 75%,150%, 200% percent.
after update to latest version
error in log:
2020-05-28 00:22:45 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 186, in _async_setup_platform
await asyncio.gather(*pending)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 295, in async_add_entities
await asyncio.gather(*tasks)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 446, in _async_add_entity
entity.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 297, in async_write_ha_state
self._async_write_ha_state() # type: ignore
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 320, in _async_write_ha_state
state = self.state
File "/config/custom_components/smart_irrigation/sensor.py", line 225, in state
self._state = self.update_state()
File "/config/custom_components/smart_irrigation/sensor.py", line 202, in update_state
self.precipitation = self.get_precipitation(data)
File "/config/custom_components/smart_irrigation/sensor.py", line 285, in get_precipitation
if retval.count(".") > 1:
AttributeError: 'float' object has no attribute 'count'
sensor:
As it appears looking at v0.50 calculations use solar radiation aswell, which is estimated using sun hours or temperatures. As weatherstatons also provide UV / Radiation sensors; i would like to opt for adding a radiation sensor option when using actual sensors.
This will make the precipitation calculation even more acurate.
upgraded to the latest version (0.0.18), removed intergation, re-added from scratch and got errors in log
2020-05-28 19:37:54 ERROR (MainThread) [custom_components.smart_irrigation.sensor] argument of type 'float' is not iterable
2020-05-28 19:37:54 ERROR (MainThread) [custom_components.smart_irrigation.sensor] argument of type 'float' is not iterable
2020-05-28 19:37:54 ERROR (MainThread) [custom_components.smart_irrigation.sensor] argument of type 'float' is not iterable
2020-05-28 19:37:54 ERROR (MainThread) [custom_components.smart_irrigation.sensor] argument of type 'float' is not iterable
2020-05-28 19:38:24 ERROR (MainThread) [custom_components.smart_irrigation.sensor] argument of type 'float' is not iterable
2020-05-28 19:38:24 ERROR (MainThread) [custom_components.smart_irrigation.sensor] argument of type 'float' is not iterable
2020-05-28 19:38:24 ERROR (MainThread) [custom_components.smart_irrigation.sensor] argument of type 'float' is not iterable
2020-05-28 19:38:24 ERROR (MainThread) [custom_components.smart_irrigation.sensor] argument of type 'float' is not iterable
Not feature request only 2 clarification questions:
Hi,
I'm new to home assistant world, I installed your component, I was wondering if I can use it to control my two irrigation valves, managed by two SV sonoff with this integration: https://github.com/AlexxIT/SonoffLAN (for original firmware). At the moment I have the two working switches (switch.sonoff_10007ca422 & switch.sonoff_10007ca743) how can I insert them in irrigation.yaml?
I'm sorry if the questions are trivial, thank you very much for your help.
Hello,
Could you explain me quickly how force mode works and the difference between maximum duration and force mode duration? I have read the wiki page but it's not clear for me.
If I want to limit daily adjusted runtime for example to base scheduled index or another fix value, what should I do?
Thanks in advance.
When irrigation is done this service should be called. But when using multiple instances, it appears it only works for the first integration..
After restart we see the following:
Also logged every 5 minutes:
2020-05-28 15:45:24 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 111, in _handle_refresh_interval await self.async_refresh() File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 177, in async_refresh update_callback() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 297, in async_write_ha_state self._async_write_ha_state() # type: ignore File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 320, in _async_write_ha_state state = self.state File "/config/custom_components/smart_irrigation/sensor.py", line 224, in state self._state = self.update_state() File "/config/custom_components/smart_irrigation/sensor.py", line 216, in update_state self.coordinator.bucket File "/config/custom_components/smart_irrigation/sensor.py", line 481, in calculate_water_budget_and_adjusted_run_time if bucket_val is None or bucket_val >= 0: TypeError: '>=' not supported between instances of 'str' and 'int' 2020-05-28 15:45:24 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 111, in _handle_refresh_interval await self.async_refresh() File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 177, in async_refresh update_callback() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 297, in async_write_ha_state self._async_write_ha_state() # type: ignore File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 320, in _async_write_ha_state state = self.state File "/config/custom_components/smart_irrigation/sensor.py", line 224, in state self._state = self.update_state() File "/config/custom_components/smart_irrigation/sensor.py", line 216, in update_state self.coordinator.bucket File "/config/custom_components/smart_irrigation/sensor.py", line 481, in calculate_water_budget_and_adjusted_run_time if bucket_val is None or bucket_val >= 0: TypeError: '>=' not supported between instances of 'str' and 'int'
Any idea howto restore these sensors without adding the integrations again?
Describe the bug
Daily Adjusted Runtime higher than Base Scheduled Index sometimes. If I undestood well, Base Scheduled Index should be the maximum time.
To Reproduce
N/A
Expected behavior
Maximum daily adjusted runtime should be base scheduled index according documentation.
Installed version
0.0.29 via HACS
Additional context
N/A
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:
Expected behavior
No error message. Not sure if is affecting the evapotranspiration calculation.
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.
requires the user to call calculate_daily_adjusted_run_time by themselves
I've probably misconfigured my setup, but I've given it a few days and I continue to see it tries to water for less than a minute.
I'm not sure what else you need to see. I guess the automation:
- id: '1562542894999'
alias: Irrigation
trigger:
- at: 05:00:00
platform: time
condition:
- above: '0'
condition: numeric_state
entity_id: sensor.smart_irrigation_daily_adjusted_run_time
- above: '0'
condition: numeric_state
entity_id: sensor.smart_irrigation_hourly_adjusted_run_time
action:
- alias: ''
data:
entity_id: switch.irrigation
service: homeassistant.turn_on
- delay:
seconds: '{{states("sensor.smart_irrigation_daily_adjusted_run_time")}}'
- data:
entity_id: switch.irrigation
service: homeassistant.turn_off
- data: {}
service: smart_irrigation.smart_irrigation_reset_bucket
I'm about to use HAsmartirrigation for a relatively large irrigation project which manages about 40.000 m2 of grassland. This involves many zones, which now need to be setup using the GUI. However, to keep a clear overview I would like to define my zones in a .yaml file.
Ideally, the integration should define CONFIG_SCHEMA and PLATFORM_SCHEMA as described here:[https://developers.home-assistant.io/docs/configuration_yaml_index]( https://developers.home-assistant.io/docs/configuration_yaml_index .)
Jeroen,
I see you use the following info from OWM:
rain = data["rain"]
snow = data["snow"]
t_day = d["temp"]["day"]
t_min = d["temp"]["min"]
t_max = d["temp"]["max"]
t_dew = float(d["dew_point"])
pressure = d["pressure"]
RH_hr = d["humidity"]
u_2 = d["wind_speed"]
For all of us having our own weatherstation we would like to make use of actual weatherdata instead of forecasted data as actual data will be much more precise, especially outside of the US.
So my request is during integration setup; ask weather to use OWM or hass sensors. When selecting OWM use the functionality as is now, when using hass sensors display 8 textboxes to insert sensor names (weatherstation doesn't know difference between rain and snow so 1 sensor for that):
daily rain
current temperature
minimum temperature
maximum temperature
dew point
air pressure
humidity
average windspeed
I hope you can see the value here, also no need to setup OMW accounts and, when using multiple instances, no redundant api calls..
Many sprinkler systems incorporate zones. These areas are often fitted with different numbers of sprinklers with different flow rates and watering times would be different for them. Any possibility of expanding this to offer the option for multiple zones? If I'm looking at this incorrectly, please let me know. I love the idea, just not sure how it fits my system.
just for transparency ... please add to base sensor attributes the following info from setup:
Second tiny thing is that units_of_measurement for every option showed in attributes could be added to the name of the attribute e,g, ( throughput [ l/min ]: 150.0 ) when "Show units in entity attributes" disabled in config. When enabled it is obvious where we will gonna see them :)
v. 0.0.22
removed integration, removed component, restart, added component, restart, added integration ->
hourly sensor unavailable:
log:
2020-05-30 13:10:17 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 186, in _async_setup_platform
await asyncio.gather(*pending)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 295, in async_add_entities
await asyncio.gather(*tasks)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 446, in _async_add_entity
entity.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 297, in async_write_ha_state
self._async_write_ha_state() # type: ignore
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 320, in _async_write_ha_state
state = self.state
File "/config/custom_components/smart_irrigation/sensor.py", line 308, in state
self._state = self.update_state()
File "/config/custom_components/smart_irrigation/sensor.py", line 286, in update_state
self.precipitation = self.get_precipitation(data)
File "/config/custom_components/smart_irrigation/sensor.py", line 410, in get_precipitation
retval = self.rain + self.snow
TypeError: unsupported operand type(s) for +: 'float' and 'str'
force irrigation to happen at the next irrigation time with fixed duration regardless of calcs.
When i look in integrations in HACS there no listing for Smart Irrigation.
is there a repository i can add for HA Add-on store
Describe the bug
after latest update when trying to open component options I'm getting infinite please wait (see screenshot)
i did removed integration, component, rebooted, reinstalled component, re-added integration ... nothing better :)
To Reproduce
Steps to reproduce the behavior:
Error log
2020-06-05 23:25:18 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 418, in start
resp = await task
File "/usr/local/lib/python3.7/site-packages/aiohttp/web_app.py", line 458, in _handle
resp = await handler(request)
File "/usr/local/lib/python3.7/site-packages/aiohttp/web_middlewares.py", line 119, in impl
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/real_ip.py", line 39, in real_ip_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 73, in ban_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 127, in auth_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 125, in handle
result = await result
File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 186, in post
return await super().post(request)
File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 54, in wrapper
result = await method(view, request, *args, **kwargs)
File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 72, in post
"show_advanced_options": data["show_advanced_options"],
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 129, in async_init
flow, flow.init_step, data, init_done
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 201, in _async_handle_step
result: Dict = await getattr(flow, method)(user_input)
File "/config/custom_components/smart_irrigation/config_flow.py", line 365, in async_step_init
return await self.async_step_user()
File "/config/custom_components/smart_irrigation/config_flow.py", line 492, in async_step_user
return await self._show_options_form(user_input)
File "/config/custom_components/smart_irrigation/config_flow.py", line 399, in _show_options_form
CONF_CHANGE_PERCENT * 100.0, DEFAULT_CHANGE_PERCENT * 100.0
TypeError: can't multiply sequence by non-int of type 'float'
Installed version
0.0.32
Additional context
sensors seems to be ok:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.