[Solved] Automation to turn on light not working

Hi all,

I have a door open/closed sensor connected to an ESP8266 running Espeasy, data is being send via mqtt, and the hass receives it, i can properly see the sensor state in the UI:

  - platform: mqtt
    state_topic: "/ESP_Easy_Spint/magnetcontact/magnetcontact"
    name: "Spinttür"
    payload_on: "1"
    payload_off: "0"
    device_class: door

Following automation to turn on a specific light when the door sensor is on is not working, also tried multiple variations after browsing this forum and the web… :-o

  - alias: Licht an im Spint bei offener Tür
      - platform: state
        entity_id: binary_sensor.spinttur
        to: 'on'
        from: 'off'
      - service: light.turn_on
        entity_id: light.dimmable_light_1

Any ideas?

Many thanks in advance,

Have you checked in Dev Tools/states that the aoutmation is enabled (on)?

That is not the case, but try removing this:

from: 'off'

Also your sensor name is Spinttür but your entity id is spinttur
I dont know how HA handles the punctuation but make sure you copied your binary sensor from the states panel. Also try renaming it to something without punctuation.
Also use quotes on your alias:

  - alias: 'Licht an im Spint bei offener Tür'

Can you manually trigger the automation using the services panel? Does it work?

One of the variations I tried, but no difference.

Copied it from there.
Also tried without umlauts, no success.

How to do that exactly?


That´s http://myip:8123/dev-state?
Nope, no automation visible there.

The reason you had no automation is probably because your automation wasnt working due to the quotes on the alias. Try again if you can see your automation.

Go to the dev panel on the left-bottom and click the first icon called “services”
At the service text box, type automation.trigger and below at the entity find your automation which should look something like this: automation.Licht_an_im_Spint_bei_offener_Tur

The service data will be auto completed. Dont touch it.

Click Call service

Tell us what happened after calling the service.

EDIT: Dont forget to go to the configuration and click CHECK CONFIG
if it passes the check, then click the reload automations button

Outch! :-o

Just saw that warning in the homeassistant journal/log:
YAML file /home/homeassistant/.homeassistant/configuration.yaml contains duplicate key "sensor". Check lines 39 and 64.

I had added the automation directly to the configuration.yaml, but at the very end an automations.yaml was included as automation.

Sorry to have stolen your time, but at least a learned couple of bits!

Anyhow, many thanks!


1 Like