dlakelan
(Daniel Lakeland)
March 16, 2022, 8:07pm
1
alias: Morning Lights On
description: ''
trigger:
- type: motion
platform: device
device_id: 1f63b4c053dd7170788116662b41d19c
entity_id: binary_sensor.officesensor_home_security_motion_detection
domain: binary_sensor
condition:
- condition: state
entity_id: sun.sun
state: 'true'
attribute: rising
- condition: numeric_state
entity_id: sun.sun
attribute: elevation
above: '-5.0'
below: '45.0'
action:
- service: scene.turn_on
target:
entity_id: scene.lights_on
metadata: {}
mode: single
In the morning when I walk into the office and the sun is between -5 degrees and 45 degrees, turn on the lights…
I can see this morning that the motion detector triggered at 7:22 AM which should have had sun rising and angle between -5 and 45… (NOAA online calculator says at that time sun elevation would have been 15.79 in Los Angeles)… but it didn’t trigger. Am I doing something wrong here?
I’m getting a little rusty, but my guess would be you have the wrong state for the first condition. I.e., the rising
attribute is a boolean, not a string. So try removing the quotes:
- condition: state
entity_id: sun.sun
state: true
attribute: rising
dlakelan
(Daniel Lakeland)
March 16, 2022, 9:22pm
3
Ok, will try that. This was actually created in the GUI editor, so the quotes were put there by the editor… meh. But thanks!
I think you can do it in the GUI editor. Just click on the three dots in that condition and select “Edit in YAML”. Then you can remove the quotes. But I don’t really use the GUI editor.
Tinkerer
(aka DubhAd on GitHub)
March 16, 2022, 9:33pm
5
The GUI editor will keep “fixing” true
to 'true'
, even when you edit other automations.
The only answer is to split the automation out into another file. For example:
automation: !include automations.yaml
automation mine: !include my_automations.yaml
1 Like
Again, I don’t use the GUI editor, so I don’t know how well this would work, but another solution could be to replace both conditions with a single template condition:
{{ is_state_attr("sun.sun", "rising", true) and -5 < state_attr("sun.sun", "elevation") < 45 }}
finity
March 17, 2022, 2:45pm
7
If the UI editor is changing a boolean to a string using an attribute (that is supposed to adopt native datatypes automatically) then this sounds like a bug that needs to be reported.
1 Like
dlakelan
(Daniel Lakeland)
March 17, 2022, 6:00pm
8
Ok, so in fact after removing the quotes using the YAML editor in the gui, it did work this morning!
I agree with @finity that this is a bug, but not sure where to report.
There’s an issue in the frontend repository already:
opened 10:43PM - 16 Nov 20 UTC
editor: automation
stale
<!-- READ THIS FIRST:
- If you need additional help with this template please re… fer 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
<!--
Describe the issue you are experiencing here to communicate to the
maintainers. Tell us about the current behavior.
If possible provide a screenshot with a description.
-->
When creating an automation in the frontend for an entity which has a Boolean value as its state, the UI adds quotes around the value. Even when editing the YAML (via the frontend) it then adds quotes when you save the automation.
## Expected behavior
<!--
Describe what you expected to happen or it should look/behave.
If possible provide a screenshot with a description.
-->
Expected that the frontend would allow for strings and Boolean values for entity states.
## Steps to reproduce
<!--
Provide steps for us, that helps reproducing your issue.
For example:
1. Add a climate integration
2. Navigate to Lovelace
3. Click more info of the climate entity
4. Set the HVAC action to heat
5. Set the temperature higher than the current temperature
6. Set the HVAC action to cool
-->
1. Create a new automation.
2. Using an entity which has a Boolean value as its state, set the trigger as (for example) `to: True`.
3. Select "Edit as YAML"
4. The UI has added quotes
5. Remove the quotes
6. Save the automation
7. Go back into the automation
8. Select "Edit as YAML" again
9. The quotes are around the Boolean value again
## 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.117.6
- Last working Home Assistant release (if known): Unknown
- Browser and browser version: Safari, Chrome
- Operating system: iOS, Windows
## State of relevant entities
<!--
If your issue is about how an entity is shown in the UI, please add the state
and attributes for all situations with a screenshot of the UI.
You can find this information at `/developer-tools/state`
-->
```yaml
```
## Problem-relevant configuration
<!--
An example configuration that caused the problem for you. Fill this out even
if it seems unimportant to you. Please be sure to remove personal information
like passwords, private URLs and other credentials.
-->
```yaml
```
## Javascript errors shown in your browser console/inspector
<!--
If you come across any javascript or other error logs, e.g., in your browser
console/inspector please provide them.
-->
```txt
```
## Additional information
However, it is stale for some reason. I don’t currently have time to read through it, but if you believe it still applies, please comment on it to prevent it from being automatically closed.
dlakelan
(Daniel Lakeland)
March 17, 2022, 7:48pm
10
thanks, added a comment and a link to this topic.