After upgrading to 0.115.0 yesterday, I started getting this error:
2020-09-19 12:25:43 ERROR (MainThread) [homeassistant.config] Invalid config for [automation]: must be a value between 0 and 59 for dictionary value @ data[‘minutes’]. Got None. (See /config/configuration.yaml, line 155).
I have this automation that was working through 0.114.4:
- id: daytime_light_periodic_90_turn_off
alias: Periodically (every 1.5 hours) turn off lights during daytime
trigger:
- platform: time_pattern
minutes: '/90'
...
I think it’s complaining about ‘/90’. Does anyone know if this was intentional change or a bug ?
`/90’ never worked the way people who used it thought it did. By that I mean it never repeated every 90 minutes. To prevent people from continuing to believe that it does do that, they now flag it with the error message you’ve seen.
This is a z-wave light switch. I have had some issues in the past in which status reporting was not reliable, so I got into the habit of never trusting the light switch correctly reporting the status to be on. That’s why I just always send a “turn off” command regardless of the status of the switch.
Hello !
I (wrongly apparently) used the time_pattern for a near reason than naustin.
Mine checked if radiator are still on “every 123mn”, in case the “OFF” triggers didn’t work (for example after a reboot).
Ex. :
You can’t have 123 minutes, because there’s only 60 minutes in the hour
You can check for the switch being on for 123 minutes, using a state trigger. There’s likely many other options, but it’s hard to solve the problem when all we have is your automation
The right way of doing what >
If you want a ‘trigger’ every 123 minutes
Then the simplest method would be to have two scripts with 123 minute delays, do your action and call the second script, which is a repeat but then calls the first etc.
You’d have to call one of them on HA start up.
Or you could trigger an automation on start up with a suplementary trigger (ie two triggers) the second trigger being to run when time == input_datetime.next_trigger_value
the first action of the action section of the automation would be to set that datetime to 123 minutes from now - then the rest of your actions after setting the next trigger
But just so you know, prior to this error message, your automation was running every 3 minutes, not every 123. The calculation is called modulo and represented by the percent symbol (%). Modulo (%) will returns the remainder when you divide 2 numbers. For example, if I do 123 % 60… 123 is divisible by 60 twice. So… 123 - (60 * 2) = 3. And that’s the remainder. This module is performed on every time_pattern field:
seconds: - modulo 60 is performed because there is 60 seconds in a minute.
minutes: - modulo 60 is performed because there is 60 minutes in a hour.
hour: - modulo 24 is performed because there is 24 hours in a day.
I’m thinking something like this should also work, but it’s cumbersome. This is doing trigger times calculation yourself and listing them out. It is slightly different since the “/X” notation is relative to the time HA started whereas this one isn’t.
- id: daytime_light_periodic_90_turn_off
alias: Periodically (every 1.5 hours) turn off lights during daytime
trigger:
- platform: time
at: "07:00:00"
- platform: time
at: "08:30:00"
- platform: time
at: "10:00:00"
...
Well, it was not clear in the doc (at least when english is not your first language) that the time_pattenr algorithm “just” uses a modulo. But it makes sense as it’s not a "job scheduler / Task planner.
I generally try not put “round hour” triggers, to avoid potential overheads of the RPi. but I switched to hours : '/2'.
(Of course, I tried “/2.05” just before to read here that it doesn’t work, but I can confirm : it does not work and send no error).
Thank you all, I’ll be able to update my hassio, but I’ll still thinking about the way to have a “every 123mn” pattern, just for science.
I agree. But it’s usually hard to explain modulo to non-programmers. If you have any pointers for the documentation to make it more clear, please make suggestions.