-
My wife always forgets to turn off one particular light when she leaves the house. I’d like to turn that light off when she leaves, but only 8AM-6PM, M-F. Something’s screwy in my code (in the condition section, I’m pretty sure), but I need help spotting it.
-
Is there a good resource for helping beginners learn the basics of YAML formatting? The initial spaces and minus signs are confusing the heck out of me.
- alias: Turn off kitchen LEDs when wife leaves
trigger:
platform: state
entity_id: device_tracker.wife_iphone
from: ‘home’
to: ‘not_home’
condition:
condition: and
conditions:
- condition: time
after: ’08:00:00’
before: ’18:00:00’
- condition: time
weekday:
- mon
- tue
- wed
- thu
- fri
action:
service: homeassistant.turn_off
entity_id: light.kitchen_uc_lights
- alias: Turn off kitchen LEDs when wife leaves
In the time condition, why do the ‘single quotes’ look odd? Maybe try changing those out. Otherwise it looks OK to me.
It’s crazy that I looked at that code 100 times and couldn’t spot the problem – and you get it on the first try. That was it! It’s working now. Thank you!
Using a linter in your text editor will help you spot most errors related to syntax. Alternatively you can use yamllint.com.
You’re right. I had used that site earlier but had forgotten about it. Thanks for the reminder.
If you use a text editor such as Atom or Sublime Text I suggest downloading a linter that automatically lints your yaml files without manual intervention.
Holy cow! Doing that now!