I'm old but trying to learn

Ok, I’m new to all this… I’m also in my 70’s

I’m trying to add an automation to turn on my bedroom lights at night if one of my aqara binary sensors is triggered.

This what I got so far and I don’t understand what is wrong. Please be patient act like I’m 10 or less, please

File editor

/homeassistant/configuration.yaml

 # Loads default set of integrations. Do not remove.
default_config:

frontend:
  themes: front door trigger themes

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

# bedroom light turn on if front door opens 
- id: turn_on_bedroom_lights
  alias: Turn On Bedroom Lights When Front Sensor Opens
  trigger:
    - platform: state
      entity_id: binary_sensor.aqara_front_door_2_contact
      state: 'on'
  action:
    - service: automation.turn_on
      entity_id:
        - tp_link_smart_switch_3ead
        - light.smart_rgbtw_bulb_a19_181
    - service: light.turn_on
      entity_id: light.smart_rgbtw_bulb_a19_181
      data:
        brightness: 255
        rgb_color: [255, 0, 0]  # Red color '

/homeassistant/configuration.yaml is the file I’m putting it in, Not even sure that is right?!?!?

Thank you

1 Like

Your automation needs to go into automations.yaml.

and not automation.turn_on, but homeassistant.turn_on

# Loads default set of integrations. Do not remove.
# bedroom light turn on if front door opens 
- id: turn_on_bedroom_lights
  alias: Turn On Bedroom Lights When Front Sensor Opens
  trigger:
    - platform: state
      entity_id: binary_sensor.aqara_front_door_2_contact
      state: 'on'
  action:
    - service: homeassistant.turn_on
      entity_id:
        - tp_link_smart_switch_3ead
        - light.smart_rgbtw_bulb_a19_181
    - service: light.turn_on
      entity_id: light.smart_rgbtw_bulb_a19_181
      data:
        brightness: 255
        rgb_color: [255, 0, 0]  # Red color '
2 Likes

Thank you, so very much

Also, not state: on in the trigger, but to: on.

It’s state: in a state condition.

Missed that one :frowning:

And that’s not a thing. Are you missing switch. before it?

if you’re just learning i would strongly recommend that you start by doing this in the ui, not in the .yaml files.

let the ui guide you. then in the ui, switch it to yaml mode and make any tweaks if you need to.

not only is it easier/faster to learn, it saves you from a lot of mistakes.

this particular thing that you want to do, i believe could be done 100% via the ui.
yes, it’ll be invaluable for you to learn how to do the yaml. so i wouldn’t recommend you totally avoid it. but if you’re starting, let the ui teach you.

it would have saved you from all mistakes above … the switch statement, where the yaml goes, all of it!

in fact, if you’ve got this yaml to work, you might try going and re-implementing it using the ui. then compare the code. you might find it quite helpful in your learning path.

4 Likes

ok. thanks. Back in the mid 80’s I thought myself Basic programming, but… I just don’t seem to understand this… YET!!!

I’m not sure how or even what you mean by doing it in the UI
But willing to learn

Thank you, I am hoping on can use this to build on. And learn a new language yaml…

hit settings icon (lower left). select automations & scenes. then hit the blue ‘create auomation’ button on the lower right.

choose “create new automation”

you’ll get something that looks like this:

for your case, you just need to do the “when” and “then do” section.

try it… it’ll walk you through it. holler if you need help with it. we’re all happy to help. i do all my automation starting with this. then after getting the bones of it right i edit the yaml (if needed). i bet the vast majority of people do that now…

1 Like

I’d really appreciate any help I can get. Thank you

that still has a bunch of issues.

here’s how the ui can help you:

then when i hit “edit in yaml” : (note ignore the error message in my screenshot, … it’s claiming an error because i’m using your entity id’s… which don’t exist on my system. when you do it on your system, it shouldn’t give you an error… or if it does, it’s actually catching an error):

and i get this:

Ok thanks I’m getting Response error: 500, but I’m still trying,

where are you getting the response error?
maybe include a screen shot that not only shows the error but shows the automation verbatim?

I’m doing something wrong, I hit save and it disappeared

I add time 23:30 to 06:00… My bad?

you might be hitting an error if the code in the automation.yaml that you tried to write by hand is invalid (which it was above). if it’s invalid, when you try to save via the ui, the ui will try to validate the file… and it could barf because you had bad yaml in it to begin with.

try removing all of your hand written code. make the yaml clean and good. the try the ui like i have…

you can use the “check configuration” (do you know how to do this?) capability in developer tools that will check for syntax errors for you:

trying to delete it

restarted :face_with_diagonal_mouth: