Frigate NVR object motion triggered light

I used a timer from Devices & Services > Helpers that is triggered by the “motion on” script, and then the timer triggers the turn off script. The timer default value sets the light’s on time.

I’m using Frigate proxy, but acting on MQTT messages. You can see the name of my camera “front_door” in the value_template config.

I check that it’s dark outside, and that the light if currently off. That way it doesn’t turn off a light that was turned on by a user. Ideally I would track “on by motion” and extend or reset the timer.

The on script:

alias: Outside Light Motion On
description: ''
trigger:
  - platform: mqtt
    topic: frigate/events
    payload: 'on'
    value_template: >-
      {{ "on" if value_json["type"] == "new" and value_json["before"]["camera"]
      == "front_door" and value_json["before"]["label"] == "person" else "off"}}
condition:
  - condition: device
    type: is_off
    device_id: bb31e928e8d8bf41f26afec557d3c5b6
    entity_id: light.outside_light
    domain: light
  - condition: state
    entity_id: sun.sun
    state: below_horizon
action:
  - type: turn_on
    device_id: bb31e928e8d8bf41f26afec557d3c5b6
    entity_id: light.outside_light
    domain: light
    brightness_pct: 100
  - service: timer.start
    target:
      entity_id: timer.outside_light_motion_on
    data: {}
mode: single

The off script:

alias: Outside Light Motion Off
description: ''
trigger:
  - platform: event
    event_type: timer.finished
    event_data:
      entity_id: timer.outside_light_motion_on
condition: []
action:
  - type: turn_off
    device_id: bb31e928e8d8bf41f26afec557d3c5b6
    entity_id: light.outside_light
    domain: light
mode: single
2 Likes