First attempt at automation not working

Hi,

This my first attempt at an automation.

In HA I have setup a ‘sensor’ called ‘sensor.doorbell_status’ that polls my doorbell every second. It detects if my doorbell is pressed. When the doorbell is pressed, the sensor state in HA goes from state ‘idle’ to ‘ring’ in ‘Overview’. So that works.

I have a Device setup called ‘Right down’ which is a LIFX GU10 LED bulb in a downlight. I can see it in HA and can turn it off/on . So that works.

I setup an Automation that should turn on the Device if the State of sensor changes from ‘idle’.

When I choose ‘RUN ACTIONS’ on the Automation in HA, it works. The lights turns on.

However when i actually press the doorbell, the light does not turn on.

Automation

Mode : Single (default)

Trigger

Trigger Type : State
Entity: sensor.doorbell_status
From: idle
To:
For:

Conditions

None

Actions

Action Type : Device
Device : Right Down
Action: Turn on Right Down
Brightness: 100

Have a chosen the wrong Type of Mode, Trigger or got the State settings wrong?
Can i check the logs somewhere to see where the breakdown might be?

I suspect it simply isnt registering the change of state in the device, however I might have confused the state shown in the Overview ‘idle’ with the real underlying entity state.

Any help is appreciated.

Go to Developer Tools States (click this)

Open your Home Assistant instance and show your state developer tools.

The check what the actual state of your doorbell sensor is, paying particular attention to capitalisation.

The other thing to check is: are you sure it is a sensor and not a binary_sensor?

Hi @tom_l ,

The State in Dev tools shows

State:
idle

I changed it from ‘sensor’ to ‘binary_sensor’ and the State is now ‘off’ instead of ‘idle’. However when the doorbell is pressed it does not change state in the HA Overview at all. So i will revert back to ‘sensor’.

What does it show when you press the doorbell button?

When I press the doorbell button it changes to ‘ring’ in both HA Overview and when I mouse over the graphical timeline in Dev Tools > States > sensor.doorbell_status > ⓘ

iot

Post your automation’s YAML.

Instructions:
If you used the Automation Editor to create the automation, look in the upper right corner and click the overflow menu (three vertical dots) then select “Edit in YAML”. Copy-paste the displayed YAML into your forum message.

alias: Doorbell press
description: Doorbell has been pressed
trigger:
  - platform: state
    entity_id: sensor.doorbell_status
    from: idle
    attribute: friendly_name
condition: []
action:
  - type: turn_on
    device_id: 351e72499d6921890eaf3a4db10471f8
    entity_id: light.right_down
    domain: light
    brightness_pct: 100
mode: single

The reason why it fails to trigger is because you added this line:

    attribute: friendly_name

Remove it.

That line instructed the State Trigger to monitor the value of the friendly_name attribute. That attribute’s value is neither idle or ring.

1 Like

ok make sense

I’ve done that now, but as it’s late here I’ll test doorbell press in morning .

I don’t recall setting that intentiionaly in Automation Editor . Not sure where that ‘friendly name’ value came from.

cheers

For future reference, it’s vital to post an automation’s YAML code. The information you provided in the first post only hints at how the automation is composed. In contrast, the source of the problem is immediately apparent when viewing the YAML code.

If you wish, the automation can be written like this:

alias: Doorbell press
description: Doorbell has been pressed
trigger:
  - platform: state
    entity_id: sensor.doorbell_status
    from: idle
    to: ring
condition: []
action:
  - service: light.turn_on
    target:
      entity_id: light.right_down
    data: 
      brightness_pct: 100
mode: single
2 Likes

ok thanks for the advice and makes complete sense now i know about the yaml file.

I only want it to trigger if the sun is down, so i added a sun.sun condition.

alias: Doorbell press
description: Doorbell has been pressed
trigger:
  - platform: state
    entity_id: sensor.doorbell_status
    from: idle
    to: ring
condition:
  - condition: state
    entity_id: sun.sun
    state: below_horizon
action:
  - type: turn_on
    device_id: 351e72499d6921890eaf3a4db10476f8
    entity_id: light.right_down
    domain: light
    brightness_pct: 100
mode: single