Sorry to create a new topic, but I’ll explain here.
OK, I’m new to Home Assistant. I’m fairly logical in my thinking, or at least I used to think so. Anyway, I’m just trying to start out basic writing yaml code, and go from there.
[My installation: I’m running a NUC with Ubuntu desktop 20.04, then installed HA in docker containers using Docker-Compose. (The reason I chose that route, instead of HAOS, is because I didn’t want to be limited by the choice of “add-ons.”) But none of that should matter here, everything seems to operate normally. I say “normal” meaning the software, UI, etc. seem to be as expected.]
However, every time I try to configure something, I keep running into the same error code on everything I do, sometimes it’s a subtle variation of that error. I tried googling it, and also searching on this form, but every time I found a link, the people were trying to do things much more complicated than what I’m trying to do.
(I do know that sometimes I overthink things, maybe that’s part of it.) If I could understand what the error code is telling me, I think I could figure out how to fix it.
I understand the importance of formatting, and I know that often times what seems like a “complicated error code” just comes down to a missing indent or a forgotten bracket (or semicolon, like in Pascal). As far as I can tell, that doesn’t seem to be the problem here.
I really though I had it this time, I’m just trying to turn off 3 lights for bedtime. The times are for weekdays vs weekends. I used the UI for most of the script, then I “opened in yaml editor.” I added 2 templates that I got from a post on this forum that are supposed to work. (In fact, my first attempt was to copy-paste the entire code, then I just changed the times, maybe a name–but got the same error when I tried to save it–even though the OP said it worked!
If someone can help me get this working…and more importantly show me how to figure out what the error message is trying to tell me, that would be MUCH appreciated! (Thanks in advance!)
Again, I created this code in the UI, starting with the switched receptacle, then clicked on “Create Automation” and added the Lights as targets. The only things I’ve done in the “yaml Editor” was to add the 2 templates (5 lines, starting with “conditions:”) and commented out a couple things I didn’t think were needed (they’re indicated with my comments).
Here’s the code:
description: "LR Lights off for bedtime"
mode: single
trigger:
- platform: time
# Do I need a helper or something to determine the time? (I first created 2 that I didn't use.) In the UI I didn't set a time.
# I'm thinking these templates should take care of of it:
condition: ["or"] # I added the "or" but the empty brackets were already there from the UI.
conditions: # this is the start of the pasted in code, total of 5 lines.
- condition: template
value_template: ''{{ now().strftime('%H:%M') == '22:30' and now().weekday() < 5 }}''
- condition: template
value_template: ''{{ now().strftime('%H:%M') == '23:30' and now().weekday() > 4 }}''
action:
- type: turn_off
device_id: 7d6c642989cdd7c6f41097d87f103b74
entity_id: switch.tpl_outlet_frog_string_lights
domain: switch
# - choose: # The UI put these 3 lines in (this + next 2), I don't think I need them so I commented them out.
# - conditions: [] # I think above replaces this, where I put the templates.
# sequence: [] # I don't need this, or maybe "immediately"
- type: turn_off
device_id: d08fe8466e05f9279698661d901d37bc
entity_id: light.tpl_light_lr_window1
domain: light
- type: turn_off
device_id: 4c65874152b90a814c78b14e38edfce9
entity_id: light.tpl_light_lr_stairs1
domain: light