Mqtt motion sensor automation issue

Hi

I am testing hassio with simulated mqtt motion sensor. I have typical issue.
I wanted to turn on switch for 1 min where there is a motion.

  1. When I enabled binary sensor using developer tools, automation gets triggered. Also I can see motion detected in UI.

  2. When I sent mqtt_publish via command line I only see motion detection on UI, automation not working

mosquitto_pub -h 192.168.1.18 -t a/b/c -m ON

Here is my automation

  • alias: Turn on kitchen light when there is movement
    trigger:
    platform: state
    entity_id: binary_sensor.motion
    to: ‘ON’
    action:
    service: switch.turn_on
    entity_id: switch.door

  • alias: Turn off kitchen light 10 minutes after last movement
    trigger:
    platform: state
    entity_id: binary_sensor.motion
    to: ‘OFF’
    for:
    minutes: 1
    action:
    service: switch.turn_off
    entity_id: switch.door


Binary sensor configuration

binary_sensor:

  • platform: mqtt
    name: “Motion”
    state_topic: “a/b/c”
    payload_on: “ON”
    payload_off: “OFF”
    device_class: motion
    qos: 0

I think your mqtt states are “ON” but binary sensors are “On”. You can check on the state page in the front end dev.

You are really Genius, Thanks a lot

Naveen

Hello Rob,

Motion sensor automation working well, How do I override automation.

How can i configure

  1. motion sensor to turn on and off after timeout. I have this is working now.
  2. Turn on/off light manually – of course working.
  3. when I turn on manually, if motion detected, automation turning off, I want to skip this

How about just one automaton?

Action
    - turn on light
    - delay 10 min
   -  turn off light

The little problem is that the light will shut off regardless if there is motion or not after 10 min. It will turn back on after motion occurs again. If you want to prevent that, I think you will need a script .

Hmm, OK let me think something else…

How can I achieve with a script ? I will try this as well

Naveen

You can use a resetable script. (not correct yaml, just action )

Action
    - turn off script - lightsoff
    - turn on script - lightsoff

script:
  lightsoff
    - turn on light
    - delay 10 min
   -  turn off light