Hi guys I am relatively new to home assistant and unfortunately I got stuck on solving my automation problem.
Set-up: I have a hue motion detector in the guest bathroom connected to Home assistant by zigbee2mqtt and a Shelly 1 switch (connected by MQTT) to control the lights there.
Use case: on motion detected and lux<22 the Shelly 1 should be triggered and the lights turned on. 30 seconds after no movement is detected the Shelly should turn off the lights.
The issue: all this currently works, however after the lights are turned off and immetiately a movement is detected again (I can see that the Hue detects motion) the Shelly is not switched on. I need to wait maybe 5-10 seconds (while constantly moving around) until the automations turns on the lights again.
Below is my code for the Shelly 1- MQTT set-up and the automations themselves.
Any help or advise is much appreciated.
Code in Configuration.yaml
switch:
- platform: mqtt
name: "Shelly1 MQTT WC"
state_topic: "shellies/shelly1-E09806961B25/relay/0"
command_topic: "shellies/shelly1-E09806961B25/relay/0/command"
payload_on: "on"
payload_off: "off"
retain: false
Automations:
- id: '1608232750852'
alias: Turn on light WC
description: Turn on light when movement detected
trigger:
- type: motion
platform: device
device_id: d8a851db123811eb80e70b97e538cf42
entity_id: binary_sensor.hue_motion_detector_occupancy
domain: binary_sensor
condition:
- type: is_illuminance
condition: device
device_id: d8a851db123811eb80e70b97e538cf42
entity_id: sensor.hue_motion_detector_illuminance_lux
domain: sensor
below: 22
action:
- service: homeassistant.turn_on
entity_id: switch.shelly1_mqtt_wc
mode: restart
- id: '1609016910773'
alias: Turn off WC Light
trigger:
- type: no_motion
platform: device
device_id: d8a851db123811eb80e70b97e538cf42
entity_id: binary_sensor.hue_motion_detector_occupancy
domain: binary_sensor
for:
hours: 0
minutes: 0
seconds: 30
action:
- service: homeassistant.turn_off
entity_id: switch.shelly1_mqtt_wc
mode: single