Complete noob here nedding help! Automation's

Hi everyone :slight_smile: this is my 1st post here for the last 5 days i have trying and trying to wrap my head around HA.
I have set HAOS up on a dedicated pc through Ubuntu and adding the OS that way I am running OS Version: Home Assistant 13.1 - Home Assistant core: 2024.8.3 i used the generic-x86-64 download.

Edit I do have HACS and i have managed to get the Alexa Notification to work

I am trying to make an automation so when I press the off button on my living room hue remote it will set off a sequence of checking if both front and back door are locked and if they’re not to send a message to my Alexa to alert me but if they’re both locked to then set my house alarm and turn my bedroom tv and lights on.

The trigger will be the “Entity”, When the State change.
The action will be “Add Building Block” then “If-then” then put the first condition, then select “Add building block” and select and to add the second condition. Then add the action you want to do.

So the trigger is whenever the state of the HUE, when it is pressed the state will change. You’re using the If-Then and AND to create a condition where when multiple things are active, it will then do the action. So you will create this for each action you want done.

How are you integrating your Hue devices into Home Assistant?

Thankyou for the quick response,
I have set it up now as
When: When Event type of Living Room Switch Button 1 changes from Initial press to Initial press

Then Do: Conditionally execute an action
Device : Front Door Lock
Condition: Front Door Lock is Unlocked

Device : Back Door Lock
Condition: Back Door Lock is Unlocked

Then*;
Action: Notifications ‘Send a notification via alexa_media_my_desk_alexa’
Message: Either Front or back door is unlocked

Then do: (on a new) Conditionally execute an action

If*;
Device: Front Door Lock
Condition: is locked

Device: Back Door Lock
Condition: is locked

Then*;
Action: Set Alarm

Action: turn on

Targets: my 3 lights in my bedroom

And then a 1min delay

Action: Turn Off
Target Main Bedroom light.

Is that correct.

Yes. Don’t for get the AND if you want both to be true if the action can proceed

My Integrations found it on my network and to set it up i had to press the button on my hue hub, and painfully having to dedicate each device to the corresponding rooms

AND IF:
Test if 2 conditions matches
DeviceDevice : Front Door Lock
Condition: Front Door Lock is locked

Device : Back Door Lock
Condition: Back Door Lock is locked

AND: Confirm the time is after 23:00

Or have i mixed that up… I am sorry it should be so simple i just cant seen to get my head around it lol.

After you’re finished with it in visual, paste the YAML here.

alias: Bedroom Light switch off at bedtime
description: ""
trigger:
  - platform: state
    entity_id:
      - event.living_room_switch_button_1
    attribute: event_type
    from: initial_press
    to: initial_press
condition:
  - condition: and
    conditions:
      - condition: device
        device_id: 495d6045c7f38978590dffa20f76bae7
        domain: lock
        entity_id: c0de5173c58d41f92c5aa26cfd50a4f6
        type: is_locked
      - condition: device
        device_id: 8d8a4dcd2c7e53df2be545935e461013
        domain: lock
        entity_id: 8e420fa880417fe853ecfd3f3f287feb
        type: is_locked
  - condition: time
    after: "23:00:00"
action:
  - if:
      - condition: device
        device_id: 495d6045c7f38978590dffa20f76bae7
        domain: lock
        entity_id: c0de5173c58d41f92c5aa26cfd50a4f6
        type: is_unlocked
      - condition: device
        device_id: 8d8a4dcd2c7e53df2be545935e461013
        domain: lock
        entity_id: 8e420fa880417fe853ecfd3f3f287feb
        type: is_unlocked
    then:
      - action: notify.alexa_media_my_desk_alexa
        metadata: {}
        data:
          message: Either front door or backdoor is unlocked
  - if:
      - condition: device
        device_id: 495d6045c7f38978590dffa20f76bae7
        domain: lock
        entity_id: c0de5173c58d41f92c5aa26cfd50a4f6
        type: is_locked
      - condition: device
        device_id: 8d8a4dcd2c7e53df2be545935e461013
        domain: lock
        entity_id: 8e420fa880417fe853ecfd3f3f287feb
        type: is_locked
    then:
      - action: alarm_control_panel.alarm_arm_away
        metadata: {}
        data: {}
        target:
          device_id: 2552845c3a40a89629d4905c754dab44
          entity_id: alarm_control_panel.yale_smart_alarm
      - action: light.turn_on
        metadata: {}
        data: {}
        target:
          device_id:
            - e3b5491e3b70d3d3ae5583b9bea82fe3
            - 934797e57aa91773f5ccc0a6ff27a8b2
            - 2d5fb5395d300119024ad77197c31c8e
          entity_id:
            - light.bedroom_lamp_1
            - light.bedroom_lamp_2
            - light.bedroom_light
      - delay:
          hours: 0
          minutes: 1
          seconds: 0
          milliseconds: 0
      - action: light.turn_off
        metadata: {}
        data: {}
        target:
          device_id: 2d5fb5395d300119024ad77197c31c8e
          entity_id: light.bedroom_light
mode: single

I don’t think the automation will run as expected. you have two mutually exclusive conditions:

in the main conditional block you have this:

condition:
  - condition: and
    conditions:
      - condition: device
        device_id: 495d6045c7f38978590dffa20f76bae7
        domain: lock
        entity_id: c0de5173c58d41f92c5aa26cfd50a4f6
        type: is_locked
      - condition: device
        device_id: 8d8a4dcd2c7e53df2be545935e461013
        domain: lock
        entity_id: 8e420fa880417fe853ecfd3f3f287feb
        type: is_locked

requiring both locks to be locked before any action is taken.

then in the first “if” block of the action you have these conditions:

- if:
      - condition: device
        device_id: 495d6045c7f38978590dffa20f76bae7
        domain: lock
        entity_id: c0de5173c58d41f92c5aa26cfd50a4f6
        type: is_unlocked
      - condition: device
        device_id: 8d8a4dcd2c7e53df2be545935e461013
        domain: lock
        entity_id: 8e420fa880417fe853ecfd3f3f287feb
        type: is_unlocked

requiring that both are not locked.

so that set of actions will never run.

the only actions that could run are the second set of “if” actions. but then only if both locks are locked.

Thank you and now i am even more confused :rofl: I am starting to think i should just do all the actions my self.

again thank you

1 Like

Don’t give up yet. Please remove the condition. Since you’re already using condition in If-Then, this is not needed.

I just cant get my head around it, I am debating on doing multiple automations with the same trigger so there will be a lot of automations happening from 1 press of the power button, would that work?

yes.

and for a new user that tends to be the easiest way to begin.

the once you have your HA legs you can then start getting fancier.

I always say that there is a fine line between having less but more complex automations and having several but easier automations. if your automations get too complicated then maintenance becomes way harder.

Thank you :slight_smile:

1 Like