tstas
October 26, 2021, 8:00am
1
The documentation states that multiple values can be provided as part of the “State” for a condition or ‘wait for trigger’.
example:
condition:
condition: state
entity_id: alarm_control_panel.home
state:
- armed_away
- armed_home
This is not working as HA is translating this into a single line and fails to pass the condition.
condition:
condition: state
entity_id: alarm_control_panel.home
state:
- armed_away, armed_home
When will this bug be fixed?
Alternativily, can a ‘state’ support a wildcard, like “armed_* ”
Bug reference: Automation editor clobbers multiple state conditions · Issue #6664 · home-assistant/frontend · GitHub
Other forum report: Bug in state evaluation
tom_l
October 26, 2021, 8:03am
2
A fix for this is being worked on:
opened 04:19PM - 20 Aug 20 UTC
bug
<!-- READ THIS FIRST:
- If you need additional help with this template please r… efer to https://www.home-assistant.io/help/reporting_issues/
- Make sure you are running the latest version of Home Assistant before reporting an issue: https://github.com/home-assistant/home-assistant/releases
- Do not report issues for custom Lovelace cards.
- Provide as many details as possible. Paste logs, configuration samples and code into the backticks.
DO NOT DELETE ANY TEXT from this template! Otherwise, your issue may be closed without comment.
-->
## Checklist
- [ X ] I have updated to the latest available Home Assistant version.
- [ 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.
## The problem
Release 0.112 added [multiple state support](https://www.home-assistant.io/docs/scripts/conditions/#state-condition) for conditions in Automations.
This is great, so I have many automations now that trigger if I'm in one of several modes. eg:
```yaml
condition:
- condition: state
entity_id: input_select.home_mode
state:
- Night
- Home
```
However, if I load this automation in the UI, the UI reads it in and displays it as
![image](https://user-images.githubusercontent.com/4708347/90796889-bff20c80-e2c4-11ea-94d3-2993492f16fd.png)
and if I save any change to any part of this automation in the UI, it clobbers the condtion and becomes:
```yaml
condition: state
entity_id: input_select.home_mode
state: 'Sleep,Night'
```
## Expected behavior
Can open and edit automation in UI with multiple states and have it save in the correct format ie:
```yaml
condition:
- condition: state
entity_id: input_select.home_mode
state:
- Night
- Home
```
instead of
```yaml
condition: state
entity_id: input_select.home_mode
state: 'Sleep,Night'
```
## Steps to reproduce
1. Edit Automations.yaml manually and create an automation with a condition with multiple states such as:
```yaml
- id: trigger_good_morning
alias: 'Trigger: Good Morning'
trigger:
- entity_id: binary_sensor.master_closet_motion
platform: state
to: 'on'
condition:
- condition: state
entity_id: input_select.home_mode
state:
- Sleep
- Night
action:
- data: {}
service: script.good_morning
mode: single
```
2. Go to the UI and load the automation "Trigger: Good Morning"
3. Without changing anything, press save.
## Environment
<!--
Provide details about the versions you are using, which helps us reproducing
and finding the issue quicker. Version information is found in the
Home Assistant frontend: Configuration -> Info.
Browser version and operating system is important! Please try to replicate
your issue in a different browser and be sure to include your findings.
-->
- Home Assistant release with the issue: 0.114.3
- Last working Home Assistant release (if known): n/a
- Browser and browser version: Firefox Version 78.0.2 (64-bit) and Chrome 84.0.4147.89 and mobile app
- Operating system: Windows and Android
## State of relevant entities
n/a
## Problem-relevant configuration
see steps to reproduce
## Javascript errors shown in your browser console/inspector
n/a
## Additional information
tstas
October 26, 2021, 8:22am
3
It seem that this PR is being closed, with the preference to use YAML instead. But even when using YAML there is a bug. Hence this fix is not really a fix…
tstas
November 4, 2021, 3:39pm
4
Anyone has a better view on either when it will be fixed? or if I’m doing something wrong I didn’t identify yet ?
tom_l
November 4, 2021, 3:43pm
5
You can use yaml instead of the GUI automation editor. Or you can use an OR condition.
tstas
November 4, 2021, 3:51pm
6
Yaml does not work either… I’ve already attempted, but the YAML editor converts it into comma separated array and that one is not well interpreted by Home Assistant…
You can try for yourself as well if you want to assess the complete behaviour…
In my case I got an automation, where within the actions I have a “wait for trigger” that evaluates the WIFI SSID connection of my phone. It only proceeds on 2 values and times out after a few minutes.
action:
- wait_for_trigger:
- platform: state
entity_id: sensor.oneplus_8_pro_wifi_connection
to: SSID1, SSID2-5Ghz
- service: script.my_script
data: {}
The “wait for trigger” never exits…
tom_l
November 4, 2021, 9:25pm
7
Like I said, don’t use the editor.
Also not sure where you got the idea the issue is closed. It is still open.
Your other option:
action:
- wait_for_trigger:
- platform: state
entity_id: sensor.oneplus_8_pro_wifi_connection
to: SSID1
- platform: state
entity_id: sensor.oneplus_8_pro_wifi_connection
to: SSID2-5Ghz
- service: script.my_script
data: {}
tstas
November 5, 2021, 10:09am
8
That’s indeed the option i currently went for… As i was configuring through the UI, adding multiple states through for the “wait for trigger” does not work. It needs to be done through YAML.
Previously I wasn’t aware that we could define multiple entries…
First occurrence yesterday was working when I came home… we’ll see for the next occurrences in the coming days…
Thanks for the help