I would like a set of conditions in an “or” fashion based on time. Between 22:00 and 06:00 I would like the click to turn the lights on a 25% and between 06:00:01 and 21:59:59, I would like to turn the lights on at 100%. The problem I am trying to solve is how in the world do you build a condition that actually causes an action.
I really stink at templates, docs just have not made sense to me yet. It look like this one will set a low brightness level from midnight to 6AM? So from say 10PM to midnight they will still come on at full brightness?
What this says if the hour now is greater than or equal to 6 and less than or equal to 21 than brightness equals 255. Any other hour which would be 22, 23 and 0 to 5 than brightness equals 64.
2018-04-23 23:41:45 INFO (MainThread) [homeassistant.components.automation] Executing Single Click 21 to toggle stair lights
2018-04-23 23:41:45 ERROR (MainThread) [homeassistant.core] Invalid service data for light.toggle: extra keys not allowed @ data['brightness']. Got '64'
2018-04-23 23:41:48 INFO (MainThread) [homeassistant.components.automation] Executing Single Click 21 to toggle stair lights
2018-04-23 23:41:48 ERROR (MainThread) [homeassistant.core] Invalid service data for light.toggle: extra keys not allowed @ data['brightness']. Got '64'
2018-04-23 23:41:51 INFO (MainThread) [homeassistant.components.automation] Executing Double Click 21 to turn off all lights
I believe so, its complaining about the value, not about the shape of the json object. So that means everythings good until the value is getting set. Using {{}} executes the command/variable/expression, so you are executing 64 which should be interpreted as an integer.
I find it’s handy using the template editor in the dev tools. Pasting your template action gave me this: (Note I removed the > after brightness) I’ve found that useful in all kinds of ways when troubleshooting.
So, I took your advice and tested it in the template editor. When I remove the “>” in question it will not pass yaml inspection. It appears that “>” tells the editor that this is a multi-line template. So, it appears it has to stay as the automation will not load without it.
Error:
missed comma between flow collection entries at line 66, column 12:
{%- if now().hour >= 6 and now(). ...
^
So, I did simplify it down to one light. HA docs do support the “,” separated list of entity_id’s and I use it other places… But, I like the keep it simple stupid idea.
But, no change same error same result.
I really think either it is not viewing the 64 or 254 as an integer.
I don’t think you can have 2 different services in one automation.
You could use a separate automation and use a condition to change the brightness when the light turns on according to the times you specified.
You could also go over to Discord and see if Dale is around as he is an absolute genius at automations. I had 8 automations last week he was able to help me condense into 2. Genius!
The toggle command works as I would expect, if I press the button the light turns on and if I press the button again it turns off. The little Mi switch sits at “0” and when pressed presents a “1” for a short bit and the returns to “0”.
This results in a state transition of each light when the button is pressed.