Does anybody know the best way to set up a Shelly Motion to use for motion detection for lights?
Basically, say you want the lights on at 10% normally, but when the motion detection is triggered, you want it to ramp up to say 100%, then back down to 10% after 5 minutes.
Is there some way to do this natively in Home Assistant?
One note is that the blind time set on the actual Motion Shelly still applies as well.
In our case, say we wanted the lights at 10% by default, then ramp up to 100% on motion, then go back to 10% after 5 minutes.
Your condition has is_off - condition is optional right? So could we simply remove this part, if we didn’t care if the lights are already off?
How do we time-out the lights back down to 10% after 5 minutes? Is there something we’d add here, or do we need to figure out some other second automation for that?
See below for adding it into a single automation. You can do two and it may simplify you maintenance. It is up to you. You can add off to the trigger and add a second option on the action choose
alias: Lights On via Motion
description: Control Lights with Shelly Motion Detection
trigger:
- platform: state
entity_id: binary_sensor.shellymotionsensor
id: off_to_on
to: 'on'
- platform: state
entity_id: binary_sensor.shellymotionsensor
id: on_five
to: 'on' <--- change to 'off' if you want no motion for 5 minutes to go to 10%
for:
hours: 0
minutes: 5
seconds: 0
condition: []
action:
- choose:
- conditions:
- condition: trigger
id: off_to_on
sequence:
- service: light.turn_on
target:
entity_id: light.your_light
data:
brightness_pct: 100
default:
- service: light.turn_on
target:
entity_id: light.your_light
data:
brightness_pct: 10
mode: single
For the Shelly Motion, during the blind time (minimum 1 minute on the device), the binary sensor in HA is still set to “On” (even if there is no motion). So this means if you want 5 minutes for no motion - then you should configure the automation for 4 minutes (plus the 1 minute of blind time).
If you edit the YAML manually in HA an automation (three dots in top right, Edit in YAML), any changes you make won’t take effect until you manually reload the Automations configuration (Configuration, Server, YAML Configuration reloading). Even doing this, for some reason, it didn’t always reload - although opening up the automation in GUI mode, and moving a slider/value there seemed to get it to reload all the time.
One idea I had was to base this on time of day - so e.g. from 09:00 to 17:00 hrs, motion would cause it to turn on to say 100%, but rom 17:00 to 0:00 and 0:00 to 09:00, it would only turn on to 80%.
@AllHailJ Am I right in thinking that condition: is the right place to set this - but that I will need to split this up into two separate automations?
Or is there some way you can see to do this in one automation? (I think it would reduce copy/pasting code to do it in one automation, so that’s reduces maintenance in one sense - but not sure if it reduces code readability…)
I believe you can accomplish in one by adding the extra condition. You could also do a trigger sensor and have the sensor be whatever percentage you wanted at the time you wanted and then use a template for the brightness.