First attempt to automation does not .... automate?

I am a HA newby. I got hass.io installed on a RPI 3 B+ with the zigbee2mqtt add-on, which was a bit of a struggle.
I now have an Aqara Human Body Movemnet sensor and an Aqara Led Bulb connected, and can read / controll them individually in the hass.io frontend.
So it was time for my first automation: switch the light on when the sensor sees movement.
I edited the automation in the hass.io web interface, this is the result in automations.yaml:

- id: '1569599241271'
  alias: SensorLampSwitch
  trigger:
  - platform: state
    entity_id: binary_sensor.0x00158d0002c636c4_occupancy
    from: 'false'
    to: 'true'
  condition: []
  action:
  - device_id: 6033e333e6db49a785e4cb95361733b2
    domain: light
    entity_id: light.0x00158d0002c67c09_light
    type: turn_on

When I wave at the sensor the light does not turn on, but the state of the sensor changes from false to true. Also, when I click on ā€˜triggerā€™ in the automation state the lamp switches on. So the separate parts seem to work, but the automation that is supposed to bring it all together does not?

This must be new, because most of the action part doesnā€™t look familiar. But since it works when you manually trigger it, Iā€™d say the problem is the states youā€™re using in the trigger. They should be 'off' and 'on' instead of 'false' and 'true'. To be sure, check the states as shown for binary_sensor.0x00158d0002c636c4_occupancy on the States page under Developer Tools.

Yeah, I must have been asleep as Iā€™ve never seen domain: and type: before
They seem to replace service: and all seem to be under the device_id:
weird !!!

Thanx, Phil. The states as shown for binary_sensor.0x00158d0002c636c4_occupancy on the States page are ā€˜falseā€™ and ā€˜trueā€™.
I changed false/true to off/on in the automation trigger and suddenly it worked! Just to check I changed it back to false/true and that worked too ā€¦
Very confusing!

Apparently thereā€™s some new features for interacting with devices. I saw mention of it but havenā€™t really read up on it. Seems itā€™s meant only to be used via the UI. (I.e., one is not supposed to manually write stuff this way.)

Was that with or without the quotes ?

Sorry, but Iā€™m not sure I believe that. Unless everything basic about Home Assistant just changed overnight. In which caseā€¦ :scream:

I mean in the State column, not if you click on the entity and look in the ā€œmore infoā€ pop up window.

Again, :scream:

Probably to make it easier for the forum peeps to help newbies with their automations :rofl: :rofl: :rofl: :rofl: :rofl: :rofl: :rofl: :rofl: :rofl: :rofl: :rofl: :rofl: :rofl: :rofl: :rofl:

All with quotes, as shown in my first post ā€¦

as Phil said : - :scream::scream::scream::scream::scream::scream:

If youā€™re using the Automation Editor in the UI, then I canā€™t really help you. I never have, and never will, use that. I can only comment about whatā€™s in the YAML file. In there, a binary_sensor can only take on two states, which are exactly 'on' and 'off'. And you have to quote these, because YAML will convert on and off (without quotes) to the boolean values true and false, which will never equal the strings 'on' and 'off'.

The states for the sensor in the ā€˜statesā€™ tab (itā€™s a tab, not a column, come on ā€¦ :wink: ) are off and on. I am still discovering new areas in HA.
But the states in the trigger part of the automation are still defined as false and true and that works ā€¦
Now I am going to figure out how I can switch the light off after 2 minutes ā€¦
Thanks for all the help, appreciate it a lot!

Red shows the STATES tab. Green shows the State column. I was referring to the latter.

Maybe in the UI, but not in the YAML file.

Oops, newbie stands corrected ā€¦
But, this is the content of my automations.yaml file, looked it up via ssh (and it works!):

core-ssh:/config# cat automations.yaml

- id: '1569599241271'
  alias: SensorLampSwitch
  trigger:
  - entity_id: binary_sensor.0x00158d0002c636c4_occupancy
    from: 'false'
    platform: state
    to: 'true'
  condition: []
  action:
  - device_id: 6033e333e6db49a785e4cb95361733b2
    domain: light
    entity_id: light.0x00158d0002c67c09_light
    type: turn_on

Interesting. May I ask, what integration are you using that is creating binary_sensor.0x00158d0002c636c4_occupancy?

Hmmm ā€¦ so I am using an integration ā€¦ neat! :wink:
I think what you are looking for is zigbee2mqtt, especially the zigbee2mqtt hass.io add-on. It interfaces a cheap zigbee hub (a cc2530 device) with a mqtt broker (mosquitto in my case). Mosquitto is what I see on the integrations page, with the 2 devices listed.

I donā€™t know a lot about mqtt, but I do know that any entity in the binary_sensor domain is supposed to only take on the states of 'on' and 'off'. It appears you have something that is breaking that rule. Maybe what you said before is correct ā€“ i.e., the states actually showed as true and false (which are, of course, strings, not boolean values, because all states are always strings.)

I also tried this experiment:

input_boolean:
  test1:

automation:
  - trigger:
      platform: state
      entity_id: input_boolean.test1
      to: 'on'
    action:
      service: persistent_notification.create
      data_template:
        message: "trigger.to_state.state = {{ trigger.to_state.state }}"

That worked. I.e., when I turned input_boolean.test1 to 'on', it triggered, and the state displayed in the notification was indeed on. Then I changed it to this:

      to: 'true'

It no longer triggered.

For me a lesson learned: no matter what works use ā€˜onā€™ and ā€˜offā€™ in the future.
Thanx again!

Iā€™m still here to tell you true and false canā€™t work if on and off do. Are you sure you donā€™t have multiple automations and the one that is firing is not the one youā€™re working on??? There is still something that doesnā€™t add up here. But if youā€™re happy, Iā€™m happy! :smile:

I changed it back to on/off in automations.yaml, and then back to true/false again, and the automation keeps working.
Only: do I need to reset or restart something after editing automations.yaml? Becuase if so I could have a cached version or something active right now?