progrmr
((aka progrmr on github/SO))
February 14, 2023, 2:27pm
1
I just discovered after debugging an automation, that this yaml doesn’t work. When you specify a before or after time you must also specify weekdays. This is contrary to logical expectations. If before isn’t specified, it isn’t applicable, if after isn’t specified it isn’t applicate, weekdays should work the same, if not specified then it should not be applicable. This is a bug or a feature request. Weekday restriction should not apply if no weekdays are specified. I’d file a bug report, but I don’t know if this is in Core, OS, FE or where.
condition: time
after: ‘12:00:00’
123
(Taras)
February 14, 2023, 2:43pm
2
I used the Automation Editor to create the following automation:
alias: "Time Condition Test "
description: ""
trigger:
- platform: state
entity_id:
- input_boolean.test
to: "on"
condition:
- condition: time
after: "09:00:00"
action:
- service: notify.persistent_notification
data:
message: Hello World!
mode: single
It contains a Time Condition without specifying any days.
At 9:38, I turned on the input_boolean and it produced a notification.
In other words, I wasn’t able to reproduce the problem you reported.
3 Likes
Like @123 , I cannot reproduce this behavior…
Home Assistant 2023.2.4
Supervisor 2023.01.1
Operating System 9.5
progrmr
((aka progrmr on github/SO))
February 14, 2023, 3:15pm
4
Hmmm, maybe it doesn’t happen in every context. I’ll try to reproduce the problem and I’ll post the entire automation.
progrmr
((aka progrmr on github/SO))
February 14, 2023, 3:26pm
5
Well, now I can’t reproduce the problem either. It seems to work fine. I had a trace where none of the Choose options were chosen but testing the conditions one of them should have been true. But apparently I was mistaken somewhere along the way in debugging the trace.
Tinkerer
(aka DubhAd on GitHub)
February 14, 2023, 3:29pm
6
You could get this kind of problem with an empty weekday
, which you can get out of the UI sometimes:
- condition: time
before: "02:00:00"
weekday:
That’ll never match, because the weekday is never blank.
1 Like
progrmr
((aka progrmr on github/SO))
February 14, 2023, 3:31pm
7
Perhaps that is what happened. I’ll have to grab automations.yaml from yesterday’s backup and see if that’s what was in there.
progrmr
((aka progrmr on github/SO))
February 14, 2023, 3:37pm
8
Yup, that was it. This is what was in automations.yaml from yesterday’s backup.
An empty weekday: list. Sounds like a UI bug to me
- choose:
- conditions:
- condition: state
entity_id: alarm_control_panel.home_alarm
state: disarmed
- condition: or
conditions:
- condition: time
after: '21:45:00'
weekday: []
- condition: time
before: 06:30:00
weekday: []
- condition: or
conditions:
- condition: trigger
id: No_hall_motion_for_half_hour
- condition: trigger
id: Late_Evening_Time
1 Like
123
(Taras)
February 14, 2023, 4:23pm
9
How did you get an empty weekday
option?
I’ve had this problem but I’m not sure how to reproduce it.
progrmr
((aka progrmr on github/SO))
February 14, 2023, 4:46pm
11
In the visual editor, if you check one (or more?) of the weekday boxes (ie: saturday), then uncheck them all, the yaml will be:
weekday: []
It looks fine in the visual editor, but it no longer works. You can’t detect the difference from the visual editor, you have to look at the resulting yaml.
progrmr
((aka progrmr on github/SO))
February 14, 2023, 5:45pm
12
Note: this is already a known bug and was fixed two weeks ago. I’m just a couple updates behind so I don’t have the fix installed yet.
opened 10:58AM - 09 Dec 22 UTC
### Checklist
- [X] I have updated to the latest available Home Assistant ver… sion.
- [X] I have cleared the cache of my browser.
- [X] I have tried a different browser to see if it is related to my browser.
### Describe the issue you are experiencing
If you create a time condition in the UI and then select a weekday, and after that remove it again, it leaves an empty list in the condition:
```yaml
- condition: time
after: "07:00:00"
before: "22:00:00"
weekday: []
```
This causes the condition to fail, as it isn't valid on any weekday now.
### Describe the behavior you expected
I would expect the `weekday:` key to be removed if no day is selected anymore.
### Steps to reproduce the issue
1. Create an automation in the GUI
2. Add a time condtion
3. Select a weekday
4. Remove the selected weekday
...
### What version of Home Assistant Core has the issue?
2022.12.1
### What was the last working version of Home Assistant Core?
_No response_
### In which browser are you experiencing the issue with?
Google Chrome 108.0.5359.99
### Which operating system are you using to run this browser?
Windows 10
### State of relevant entities
_No response_
### Problem-relevant frontend configuration
_No response_
### Javascript errors shown in your browser console/inspector
_No response_
### Additional information
_No response_