Sorry xbmcnut I will not find the time to create a working example without all other stuff I have in there… The C&P above should help you along the way … the template sensors are the most important parts as they calculate the next run based on how the sliders and input select are set.
Please note that the function now should be replaced by now() since 29
Hi Ron. Of course, I completely understand and in hindsight, it would probably be above my capabilities at the moment (I’m a hardware guy) are an overkill for my requirements. All I’m attempting to do is the following:
Schedule my two water valves on at 0630 everyday for 20 minutes with an input slider for the timer value
Check the state of my rain gauge (wet/dry) as a condition to prevent firing if wet
Have the timer fire based on the state change of the valve so that the timer always works, even if the valves are manually turned on. This is how it is set up with PLEG in my Vera which I’m trying to replicate in HA.
I’m learning YAML but it is a steep learning curve for a hardware guy, especially when the formatting in all of the examples on the main webpage bare no reference to the required formatting when you split your config up (which is kind of mandatory if you have more that a half-dozen devices).
This is where I’ve got to which I’m happy with (about 6hrs latter!) but is a way from where I need to be.
Please see also the group documentation on how to use view: yes together with the default_view to create your own layout in the front end. If you got that than the trick is easy as the above basically creates an entry for the Sprinkler in the top menu of the frontend that shows the view for the group valve_1_status. Now the last line in the view valve_1_status is another group group.valve_1_settings.
The effect is that the group.valve_1_settings is only shown if you click on the Settings in the view of valve_1_status.
Basically you need to create an automation rule that triggers on turning a valve on. This should include a condition based on “Use Timer for Sprinklers” if that is ON/TRUE than turn_on script that turns them off after a set delay.
Thank you, that’s a big help. I’ve made some progress this evening but could not pass the value from the input_slider so I’ll try replicating your scripts over the weekend and see how I get on. I had this from a previous post but it does not work.
water_timer_off:
alias: "Turn off water after (input select) minutes"
sequence:
- delay:
minutes: '{{ input_slider.timer_options_slider }}'
- service: homeassistant.turn_off
data:
entity_id: group.water_valves
delay: '00:{{ states.input_slider.timer_options_slider.state | int }}:00'
I see you have 2 times a delay in there … not sure if that works
another tip is try to evaluate your template in the developer tools under Templates. That will show you how the template renders the output as a common issue here with time is that you get one digit back and than your delay looks like 00:5:00 and that will not work.
Search in this forum on the topic alarm clock and you will find lot of entries how other have solved some of the issues with this
Hi Ronvl,
Suspect that Im getting the below errors due to the now function change.
Can you help identify which of the now statements need changing? Below is an example of a few instances I have found - unsure which examples need changing.
Currently getting a couple errors in the log file on 0.30.2.
16-10-14 23:55:44 homeassistant.components.sensor.template: UndefinedError: ‘function object’ has no attribute ‘weekday’
16-10-14 23:55:44 homeassistant.components.sensor.template: UndefinedError: ‘None’ has no attribute ‘last_changed’
I’m not near HASS at the moment but it looks like you have two times as_timestamp(now) that need to be changed to as_timestamp(now()) I believe. You can test it via the developer tools under Templates, just past it in there there … way easier than starting the HASS every time
Please be aware that the Status that shows how long the Valve is open is not working anymore since 29.5…
See:
If you follow the links to the PR you will find a work around that I haven’t tested yet… as it is authum here in Germany and getting below zero at night the sprinkler is currently not installed
I noticed that if i restart hass the parameters i set are not saved and rolls back to default.
For example the select sensor returns back to its default which is None.
Also the time and duration is reset to default.
Instead of automation with slide bars for,hour and minute and days, I moved my logic to be control with a google calendar with the latest release.
My sensor Based on the calendar searches for Bed 1, which is my sprinkler in one of my raised bed, it uses the state = on to turn it off, but I still set the off with a timer set with a slider and a Mqtt command
to create a sensor for when I last ran the sprinkler automation. The issue I’m having is the time here isn’t my “local” timezone it’s the UTC timezone that home assistant runs everything with in the background. How can i translate to my local time with the strftime?
@thejacko12354 that code is a bit old and now.weekday() is replaced by now().weekday(). have a search on the release notes as there were a few changes since
@ronvl yeah i found that error.
Now I’m stuck with the next one…
If I set a day, I get this error:
Traceback (most recent call last):
File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step
result = coro.send(None)
File "/usr/lib/python3.5/site-packages/homeassistant-0.36.0.dev0-py3.5.egg/homeassistant/helpers/entity.py", line 212, in async_update_ha_state
yield from self.async_update()
File "/usr/lib/python3.5/asyncio/coroutines.py", line 206, in coro
res = func(*args, **kw)
File "/usr/lib/python3.5/site-packages/homeassistant-0.36.0.dev0-py3.5.egg/homeassistant/components/sensor/template.py", line 114, in async_update
self._state = self._template.async_render()
File "/usr/lib/python3.5/site-packages/homeassistant-0.36.0.dev0-py3.5.egg/homeassistant/helpers/template.py", line 99, in async_render
return self._compiled.render(kwargs).strip()
File "/usr/lib/python3.5/site-packages/jinja2/environment.py", line 989, in render
return self.environment.handle_exception(exc_info, True)
File "/usr/lib/python3.5/site-packages/jinja2/environment.py", line 754, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/lib/python3.5/site-packages/jinja2/_compat.py", line 37, in reraise
raise value.with_traceback(tb)
File "<template>", line 66, in top-level template code
File "/usr/lib/python3.5/site-packages/jinja2/sandbox.py", line 355, in call
return __context.call(__obj, *args, **kwargs)
File "/usr/lib/python3.5/site-packages/homeassistant-0.36.0.dev0-py3.5.egg/homeassistant/util/dt.py", line 79, in as_timestamp
raise ValueError("not a valid date/time.")
ValueError: not a valid date/time.