šŸ’” Sensor Light - Motion Sensor - Door Sensor - Sun Elevation - LUX Value - Scenes - Time - Light Control - Device Tracker - Night Lights

Hi everyone, this is my first post again after being away for a few years from HA.
I love the new changes and am busy with the blueprints.
I’ve started using Sensor Light and can’t seem to get it to act the way i want it to… Here’s my scenario:

I have a light in the bathroom that i want to be turned on by an occupancy sensor in that same bathroom. It should turn on with brightness at 100% and at a color of 6500k.
Between 10pm and 6am i want it to turn on at 10% brightness at a color of 2000k. This is all working perfectly so far. The thing i want to add is a bypass…
When i press the light switch in the bathroom (which is detached and functions as a button only) i want the light to go on, regardless of it’s current state at maximum brightness and at 6500k. So basically identical to the times when the night light option isn’t active…
At the moment the night light function works. But when i press the bypass button it only turns on the light as defined in night light…
So if i press the button between 10pm and 6am the lights go on at 10% at 2000k. and outside that time window it goes at full brightness 6500k…
I want the button to overrule everything and just turn on the light at 6500k max

The components i use are:
Philips Wiz Light
Sonoff SNZB-06P occupancy sensor
Sonoff ZBM5 single gang zigbee switch
Sonoff Zigbee Dongle Max

In sensor light the trigger is the occupancy sensor.
in Light i have the wiz light
Light Control i have ā€œUse Brightnessā€ set at 100% and ā€œUse color temperatureā€ set at 6500k
Under Bypass i have option 1 only. Turn the lights on
The Bypass switch is the sonoff switch
I have enabled night light settings: enable night light options, enable time option (10pm for start, 6am for stop)
Under night light i have selected the wiz light again
night light control is Use Brightness set at 1% and color control at 2000k

i must be misssing something…

I would love to this automation to have an input_helper as trigger

I have an automation that sets the occupancy of an area (for example input_helper.kitchen_occupied)

The automation sets the state based on opening of doors, triggers by motion sensor etc…

But this blueprint does not allow the input_boolean to be used as input.

@nikosta

Yes that is correct, when you switch OFF a bypass (all must be OFF if you have more than one) it will then check the site conditions and turn the light ON if motion is detected.

Blacky :grinning:

@camcoding

This blueprint must be triggered by an ON / OFF state. Your state ā€œviolatedā€ or ā€œnormalā€ and is a sensor not a binary sensor. Not sure if you can convert your sensors to binary sensors as binary sensors will have an ON / OFF state. Failing that you will need to create the binary sensors or if you have a simple automation (not using all the added features in this blueprint) you could just create an automation that will be triggered on your current states.

Blacky :grinning:

@nart.wdl

You have a few conflicts.

  1. Remove your Scenes & Scripts - Toggle Helper, your not using a scene or script. Your using a light.
  2. Remove your Scenes - Scripts To Turn OFF, your not using a scene or script. Your using a light.
  3. Disable Sun Elevation or Dynamic Lighting as your have conflicts to when the light can turn ON in your sun elevation. Your dynamic lighting min deg is 15 and sun elevation is -1.5.

Blacky :grinning:

@malocycling

I would need your YAML of your settings to confirm this but my bet is you have enabled night glow option and that will turn the light ON when night lights is active.

Blacky :grinning:

@rgroothuis

You must have a input in **Lights - Switches - Scenes - Scripts **. If you just want one option then add you light into **Lights - Switches - Scenes - Scripts **. Disable night lights and use your night time entity in State Control. Then it will work.

Blacky :grinning:

@Valdorama

With 50% ā€˜dim before off’ percentage and your actual light % is 80% then it should dime to 40% and go back to 80%. I just tested this set up and it works on V8.5.

Blacky :grinning:

@Mgs

You could have the day at 100% and then make night lights do your 100% + night glow of 75%… then when you would like your 1% night glow you will need another automation using this blueprint :high_brightness: Smart Light - Entity - Sun Elevation - Ambient & Time Triggers. Trigger it to come on at 1% for the time period (both blueprint automation must be set up so there are no conflicts for this period) and then in night lights use your motion sensor as the state option and in night light control make sure you select Use cross over time delay from night lights to normal lights and If lights are ON, adjust the lights when crossing over.

Blacky :grinning:

@fardavide91

First I would try disabling dynamic lighting and see if that helps. If that is okay then enable dynamic lighting but you have a 1% brightness level for DL - Min Brightness Value and some lights don’t like that low so maybe increase it to higher value. In dynamic lighting you also have a Dead Zone of 0 and I would recommend something in there like the default of 7. Also so a step value of 1% should be increased, try the default of 4.

Blacky :grinning:

1 Like

@SEWFlyers

Yep Home Assistant made this change in a update, it been reported to them but I don’t think they care about it. It still works you just have the red error message.

Yes it is restart.

Blacky :grinning:

1 Like

@eqlipseaudio

Yes that is correct if night lights is enabled and active and you turn the bypass ON it will apply your night light settings.

What you could try and do is keep the bypass as is in this blueprint automation but create another custom automation so when you turn ON the bypass it sets the light to 100% - 6500K. Then the blueprint will turn it OFF for you.

Blacky :grinning:

@jammiejammie

Because HA changed things again you can’t just paste it into the input so to do this now copy your input helper entity ID, go into your automation, make sure you enter in a any trigger, then top right 3 dots, select Edit in YAML, then look for this in your settings (see below code), you will have something different to input_boolean.testing_motion_sensor but replace this with your entity ID of your input_boolean. Save and your done.

    motion_trigger:
      - input_boolean.testing_motion_sensor

Blacky :grinning:

Works perfectly!
Maybee add the input_boolean to the selectable options list in the next update?

1 Like

Hey trying to setup the Garage Auto Off template. but i think the problem i have is the entity is set as Open/Closed instead of on/off. How to i convert it to on/off or whatever i need to get the automation to trigger. I have a plan to use the garage door open/closed sensor, a door sensor, and camera person detection. i’m not sure yet how im going to make it work. i put a motion sensor in and its not quite responding or reading well enough for what i want.

template:
  - trigger:
      - trigger: state
        entity_id: cover.door_1
        to: "open"
    binary_sensor:
      - name: "Garage Door Auto Off"
        device_class: garage_door
        icon: mdi:garage-open-variant
        auto_off: 
          minutes: 5
        state: "true"

@killahawk0234

You don’t need a trigger template. This is how you do it.

  1. Go to Settings > Devices & Services > Helpers.
  2. Click ā€œ+ Create Helperā€ and choose Template > Binary sensor.
  3. Set a Name for your new binary sensor.
  4. In the State template field, paste the code below.
  5. Set the Device class if you want this binary sensor to behave like a door sensor, etc.
  6. Optionally, select a Device to link this sensor to. Leave it blank if not needed.
{{ is_state('cover.door_1', 'open') }}

Blacky :grinning:

Dear,

I’m using this blueprint with for about 1 year and it’s a very nice blueprint! Works like a charm.

But I’ve one question: i’m controlling Philips Hue with this blueprint (all my lights in house are Hue).
Sometimes I want to browse through the Hue app to select a new scene (also Hue updates these scenes regulary).

How can I automatically disable the Blueprint for for example 3 hours when I’ve selected a manual scene in the Hue app?

I know I can use overrides in the blueprint, but I don’t think I can ā€œdetectā€ Hue app usage as an override in the sensor blueprint.

Anyone?

Many thanks!
Pieter

But how would i get it to ā€œresetā€ with the auto off 5 minutes?

EDIT: Please ignore this - I now see you’re supposed to provide (or create) a binary helper to track when the lights have been auto-dimmed. Did that and it works well now. :+1:

HI @Blacky - the issue seems to be that it is trying to restore the brightness when it doesn’t need to. For example, I have the ā€˜turn off timer’ set to 10 mins, and the ā€˜dim before off’ duration set to 30 sec. I’m assuming it should work like this:

* Motion detected - lights on @ 80% brightness
* 9min 30s of no motion - lights dimmed by 50% - so 40% brightness
* Motion within 30s - lights restored back to 80% brightness

Looking at the trace though, the automation is trying to restore brightness when motion is detected before the ā€˜dim’ period. I walked into the room and lights turned on. I walked back in after 2-3 mins (so well before the 9min 30sec deadline) and the lights changed to 100%.

The trace shows that this condition was executed:

alias: If dim before OFF is selected - Restore Lights
conditions:
  - condition: template
    value_template: '{{ include_dim_before_off == ''dim_before_off_enabled'' }}'
  - condition: state
    entity_id: []
    state: 'on'
sequence:
  - repeat:
      for_each: '{{ light_entities }}'
      sequence:
        - variables:
            restore_bri: >
              {% set bri = state_attr(repeat.item, 'brightness') %} {% if bri in
              [None, 0] %}
                {{ 0 }}
              {% else %}
                {% set bri_pct = bri / 255 * 100 %}
                {% set restored = bri_pct / dim_before_off_factor %}
                {{ [restored | round(0), 100] | min }}
              {% endif %}
            restore_light_data: >-
              {% set light = namespace(data={}) %} {% if 'use_transition' in
              include_light_control %}
                {% set light.data = dict(light.data, **{ 'transition': light_transition_on }) %}
              {% endif %} {% set light.data = dict(light.data, **{
              'brightness_pct': restore_bri }) %} {{ light.data }}
        - action: light.turn_on
          target:
            entity_id: '{{ repeat.item }}'
          data: '{{ restore_light_data }}'
  - action: input_boolean.turn_off
    target:
      entity_id: []

However there was no need to restore the lights at that point. Should the condition template check that ā€˜dim before off’ is enabled AND that we’re in the dimming period?

1 Like

sure, here you go. I’m not using night glow. Have played with dynamic lighting before but it’s not enabled. This is version 8.5 btw.

alias: Bad.sensor_light
description: ""
use_blueprint:
  path: Blackshome/sensor-light.yaml
  input:
    motion_trigger:
      - binary_sensor.bad_presence_belegung
    light_switch:
      entity_id:
        - light.bad_decke_leuchte_2
    include_light_control:
      - use_brightness
    include_dim_before_off: dim_before_off_enabled
    dim_before_off_pct: 20
    dim_before_off_time_delay: 10
    dim_before_off_boolean: input_boolean.bad_motion_dim_toggle_helper
    include_sun: sun_enabled
    sun_elevation: 8
    sun_elevation_rising: 9
    time_delay: 1
    light_brightness: 67
    boolean_scenes_scripts: input_boolean.bad_decke_helper_toggle
    end_scenes: []
    include_time: time_disabled
    before_time: "22:00:00"
    after_time: "06:00:00"
    include_dynamic_lighting: disable_dynamic_lighting
    dynamic_lighting_max_lux: 1500
    dynamic_lighting_min_lux: 0
    dynamic_lighting_max_brightness: 60
    dynamic_lighting_boolean: input_boolean.bad_decke_dynamic_helper
    dynamic_lighting_min_brightness: 20
    night_lights_conditions:
      - time_enabled
    night_lights_after_time: "22:00:00"
    night_lights_before_time: "06:00:00"
    include_night_light_control:
      - use_brightness
      - if_lights_are_on_adjust_when_crossing_over
      - manage_scripts_crossing_over
    night_light_transition_off: 0
    night_time_delay: 1
    night_lights:
      entity_id:
        - light.bad_decke_leuchte_2
    night_light_dim_before_off_boolean: input_boolean.bad_motion_night_dim_toggle_helper
    include_night_lights: night_lights_enabled
    night_light_include_dim_before_off: dim_before_off_enabled
    night_light_dim_before_off_pct: 10
    night_boolean_scenes_scripts: input_boolean.bad_motion_night_toggle_helper