Junikorn
(Błażej Wolańczyk)
November 29, 2021, 9:11pm
1
I have automation that is using state
condition and trigger. I read in documentation that if you use list in state
condition or from
in trigger it will act as or
on listed states. Debug I have done on my automation shows otherwise:
result: false
state: cloudy
wanted_state: cloudy,snowy,rainy
I can make it work with multiple triggers and or
condition but I would like to know what am I doing wrong. Would be grateful for any feedback
Full automation code:
id: '1638088596150'
alias: Włącz doświetlacz przenośny po zachodzie lub gdy jest ciemno
description: ''
trigger:
- platform: state
entity_id: weather.miloszyce
to: cloudy,snowy,rainy
for:
hours: 0
minutes: 5
seconds: 0
milliseconds: 0
- platform: sun
event: sunset
offset: '0'
- platform: time
at: '07:00'
condition:
- condition: time
after: '07:00'
before: '21:00'
- condition: or
conditions:
- condition: sun
after: sunset
- condition: state
entity_id: weather.miloszyce
state: cloudy,snowy,rainy
for:
hours: 0
minutes: 0
seconds: 0
milliseconds: 0
action:
- type: turn_on
device_id: 29e0f59e4aa58ad01673a4d992bd1405
entity_id: light.mobile_plant_light
domain: light
mode: single
r-j-taylor
(R. J. Taylor)
November 29, 2021, 9:54pm
2
Selective reading of the docs is not very helpful
You are not supplying a list, you are supplying a state of cloudy,snowy,rainy
, which will never be true (ETA: turns out this was accidentally true). Here is one of the list examples from the docs, showing proper format:
condition:
condition: state
entity_id: alarm_control_panel.home
state:
- armed_away
- armed_home
This will be the format for anything that is defined as a YAML list
, you are not able to make up your own format.
tom_l
November 30, 2021, 1:40am
3
This:
to: cloudy,snowy,rainy
is the same as
to:
- cloudy
- snowy
- rainy
However the GUI editor malforms either of these list formats to:
to: 'cloudy,snowy,rainy'
Which is definitely not a list and not correct.
If you want to use lists you need to use YAML, not the GUI editor.
It looks like this will happen automatically (drop back to YAML editing) in future:
opened 04:19PM - 20 Aug 20 UTC
closed 09:14AM - 29 Nov 21 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
1 Like
r-j-taylor
(R. J. Taylor)
November 30, 2021, 1:44am
4
Huh, TIL. Never seen that before, thanks for the correction!
Junikorn
(Błażej Wolańczyk)
November 30, 2021, 8:29am
5
I was aware of this and checked in YAML before asking the question here. As you can see in attached automation config quotes were not added but it still didn’t work. I was also assuming that visual editor was the culprit here, but it seems to work correctly in this case. I find it weird
tom_l
November 30, 2021, 8:42am
6
Doesn’t matter the GIU editor adds them.
Junikorn
(Błażej Wolańczyk)
November 30, 2021, 8:54am
7
Ok I will edit with VS Code only and see if it helps. It is weird that yaml editor part of the ui editor and config preview of debugger were not showing the quotes though. Thanks for assistance
Junikorn
(Błażej Wolańczyk)
November 30, 2021, 9:46am
8
I edited automatons.yaml
by VS Code to be sure and reloaded automations. Automation still fails on condition check with comma separated list. Fallback to dashed list solves the problem. There might be an issue with condition checker since comma separated list was definately not in quotes this time.
1 Like