Hi, I have the stock standard motion-activated light automation in HA and recently it’s been hit and miss with when it works and doesn’t work.
Lights - I have Shelly switches connected to my light switches and through HA all working through Shelly app.
Motion Sensors - I use Sonoff Zigbee motion sensors connected through HA all working through Tuya App.
Can anyone tell me why it’s hit and miss? I have 3 x motion sensors that set off 3 different lights, I’ve noticed when one isn’t working, all of them aren’t.
If anyone else has a better way to do motion sensor lights or can point me in the right direction, I’d love to know. Or if you can fix this? I use them in my pantry, walking in linen and walk in robe, because otherwise my wife leaves them on. So I want them to come on with motion and go off at a set time.
There is no stock automations in HA, so please show the yaml code.
It might be obvious to you, but not to us.
What doesn’t work? Is motion detected but light not turned on? Is motion not detected? Is the automation not triggered?
If the automation is triggered, please provide traces.
Bottom-line: I, personally, would probably not be able to help you, but please give yourself a chance to get an answer by providing enough information in your initial post.
Not everyone (few, actually) are willing to spend time extracting the needed information from you.
This turns on two lamps when motion is detected and leaves them on for 10 minutes. If someone turns on one of the lights manually, it will also leave it on for 10 minutes. If the light level in the room is sufficient not to need a light, they don’t come on.
Hi, thanks for taking the time to reply. Sorry I don’t know the slang, stock standard should read blueprint.
The code, when you create an automation using the blueprint.
blueprint:
name: Motion-activated Light
description: Turn on a light when motion is detected.
domain: automation
source_url: https://github.com/home-assistant/core/blob/66b105fb21ac7d2c0250f792faa924109961489d/homeassistant/components/automation/blueprints/motion_light.yaml
input:
motion_entity:
name: Motion Sensor
selector:
entity:
domain: binary_sensor
device_class: motion
light_target:
name: Light
selector:
target:
entity:
domain: light
no_motion_wait:
name: Wait time
description: Time to leave the light on after last motion is detected.
default: 120
selector:
number:
min: 0
max: 3600
unit_of_measurement: seconds
# If motion is detected within the delay,
# we restart the script.
mode: restart
max_exceeded: silent
trigger:
platform: state
entity_id: !input motion_entity
from: "off"
to: "on"
action:
- alias: "Turn on the light"
service: light.turn_on
target: !input light_target
- alias: "Wait until there is no motion from device"
wait_for_trigger:
platform: state
entity_id: !input motion_entity
from: "on"
to: "off"
- alias: "Wait the number of seconds that has been set"
delay: !input no_motion_wait
- alias: "Turn off the light"
service: light.turn_off
target: !input light_target
So motion is detected, but light doesn’t turn on. Yet I can go into the app or HA and use buttons to manually turn this lights on, suggesting it’s the automation not the connectivity with the devices. Hence, automation not triggered.