After reading some posts I came up with the automation file below but then Hass reboots in safe mode and throws all kind of errors saying that it doesn’t understand the file.
- alias: Living room lamp on
trigger:
platform: sun
event: sunset
offset: '-01:00:00'
action:
- service: switch.turn_on
entity_id: switch.Livingroom_lamp
- alias: Living room off at 11PM
trigger:
platform: time
at: 23:00
action:
- service: switch.turn_off
entity_id: switch.Livingroom_lamp
Can anybody help me with an automation file to turn GPIO 04 on 1 hour before sunset and off at 11PM?
Without digging too deep into this, I can see at least one syntax error. The entity id Livingroom_lamp has a capitalized L. Try replacing Livingroom_lamp with livingroom_lamp and try it again. Then, if you want to see “Living-room Lamp” in your dashboard, just add the friendly_name: field to your switch config.
Capital letters (and whitespace) in names is generally a no-no when it comes to yaml. The exception being fields where HA parses the variable name (like friendly_name: and alias:). So “Living room off at 11PM” works, because HA will automagically convert the alias: field, and internally refer to it as living_room_off_at_11pm. However, HA does not parse the entity_id: field. So any capitals there will result in invalid yaml.
Also, I recommend always using the configuration checker button before rebooting. It can save you from major headaches.