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

Thanks for reply.

By-pass is definitely a cool feature but it does function completely opposite of what Iā€™m trying to achieve here:)
I want my switch function just the same as if the sensor detected movement, thatā€™s all.

@Anaconda

You could try this if you are keenā€¦ note I have not tested and just did the code here quickly. This is my thinking.

Create a button helperā€¦ when you push it, it will turn on the new sensor if the total room sensor is ON. Then when your total room sensor goes OFF your sensor light automations time delay starts. I put a delay of 30 seconds just to give it a buffer if it comes back on but you can remove it or make it longer, like this for 10 minutes change the seconds to minutes in the template.

          minutes: 10

Create a your template binary sensor by adding this to your ā€œconfiguration.yamlā€ file. Then restart HA or reload as shown below. You will have to change ā€œinput_button.your_button_helper_hereā€ to your button helper entity ID and ā€œbinary_sensor.your_total_room_sensor_hereā€ this is your entity id for the total room sensor. The ā€œButton Motion Sensorā€ is the name of your new sensorā€¦ change it to your liking.

template:
  - trigger:
      - platform: state
        entity_id: input_button.your_button_helper_here
      - platform: state
        entity_id: binary_sensor.your_total_room_sensor_here
        to: "off"
        for:
          seconds: 30
    binary_sensor:
      - name: "Button Motion Sensor"
        device_class: motion
        icon: mdi:motion-sensor
        state: >
          {{ is_state('binary_sensor.your_total_room_sensor_here', 'on') }}

Once done then group this new binary sensor with the zone motion sensor in each automation. So you will have say zone 1 + this sensor in a group, then zone 2 + this sensor in a group. Then add the correct group to the automation trigger for the zone (only this group in the trigger). Now when you push the button it should turn ON this new sensor in every group turning ON all your lights or keeping them ON and only when the total room motion detection goes OFF then this sensor will go OFF and your lights will turn OFF :wink: Nice hay :partying_face: No need for by-pass and your two automationsā€¦ you only need this temple sensor. :tada:

To reload the template sensor if you make a change go into developer tools and click"template entities"

Hope it worksā€¦ it should

Let us know if this works for you

Blacky :smiley:

1 Like

A switch is not a motion sensor. You have to turn it ON manually and something has to turn it OFF.

So you could use the by-pass turn light ON with the delay to turn it OFF if you forget. When you turn the switch ON light will come ON or Stay ON and then the delay will turn it OFF if you forget to turn it OFF and your light will go OFF.

Blacky :smiley:

Thank you so much for this. I will give this a try for sure and let you know !!

1 Like

Ok so I have just done it and here is the outcome :slight_smile:

  • When I push the button, all lights come on and stay on while whole room presence is detected.
  • When I leave the room, the lights stay on for 30 seconds (I guess) and if no presence, turn off.
  • When I come back only the zone where I am in turn on, however, when I move from zone to zone, some zones now donā€™t turn on, (depending on which order I walk/change zones in the room, those which donā€™t turn on are different) while they were before in same conditions. I have ambient options enabled for all zones and checked that it is affected by lights.

Any idea what the issue could be ?

Thank you !!!

EDIT: So I have disabled the ambient options and now it all lights come on normally ā€¦ I donā€™t know why it worked previously without issue and not now.

@Anaconda

Looks like the template sensor works :+1:

Try this to work out the bugs.

  1. Disable ambient lights in all automations.
  2. Add to your dashboard each zone and the total room detection + the new template sensor so you can look on your phone as you walk around to see what is being triggered. This way you can check the zones triggers to the automations.

Okay so now in your ambient light options try this.

  1. Donā€™t select the site conditions to yes. Select ā€œNOā€. This is because one automation is effecting the other one.
  2. When it is dark outside, turn all your lights ON 100% brightness and see what your ambient LUX sensor is . Say it reads 100 LUX. Then set your ā€œAmbient Light - High Lux Valueā€ to 120 lux and adjust higher if the light ever turn OFF when you would like them ON. Set all your automations to this. That is if your ā€œAmbient Light - Low Lux Valueā€ is a lower setting. The ā€œAmbient Light - High Lux Valueā€ must always be = or higher than your low setting.

EDIT: You will also need to play around with the ā€œAmbient Light - Low Lux Valueā€ to get that right so the other automation will trigger ON.

EDIT: Or you can select ā€œYESā€ but your ā€œAmbient Light - Low Lux Valueā€ must be higher when all your lights are ON.

Let us know how you go.

Blacky :smiley:

Thank you very much !!! At least I know where the issue comes from, so I will play with the ambient light setup.

I hope some day you will create a blueprint for the Aqara FP2, it is a great presence sensor when it works, but needs a lot of knowledge to set it up. Without your help, I would have sent it back for sure !

No problem, your welcome.

If you have brightness control then forget about ambient and try and use the dynamic lighting in the automations.

Yea, maybe if Aqara is reading this they will send me out one.

Enjoy

Blacky :smiley:

1 Like

Hey there.
Amazing job with so complicated blueprint. Iā€™m trying to get it to work with the Aqara P1 motion sensor and I canā€™t. So I have configured the minimum required fields and I didnā€™t even get automation triggered.

alias: New Kitchen Lights
description: ""
use_blueprint:
  path: Blackshome/sensor-light.yaml
  input:
    motion_trigger:
      - binary_sensor.motion_kitchen_occupancy
    light_switch:
      device_id: cd4368f348b055e070ae573f246a9db2

@oleksii-kalinin

Firstly welcome to the community :wave:

You are using a device and you can only use entities so you will need to expand down to entities. Then it will work.

A good starting point is to read ā€œThe Settings & Best Practice Guidelinesā€ Click Here.

Blacky :smiley:

1 Like

thanks it works BUT i can only have one bypass option so either one button to turn it on or offā€¦ it doesnt sadly have a feature to toggle the bypass on and off with one button

Thanks! (for the welcome and advice)
Changed to the entity and automation works.

alias: New Kitchen Lights
description: ""
use_blueprint:
  path: Blackshome/sensor-light.yaml
  input:
    motion_trigger:
      - binary_sensor.motion_kitchen_occupancy
    light_switch:
      entity_id: light.kitchen_lights
    time_delay: 3
1 Like

it should toggle the by-pass ON and OFF. What state is your button, what does it do when you push it?

I am on 4.7 so donā€™t have the dynamic lighting option. I am looking into information on how to update the blueprint ā€¦ Is there an easy step by step guide ? i never done it before ā€¦

@Anaconda

Yep it is easy and in the FAQ

Q: How do you update the blueprint and not delete / recreate existing automations?

A: Please follow these steps Click Here.

1 Like

thank you very much very clear, done in 2 minutes, easy peasy :slight_smile:

About Dynamic lighting you suggested, I am now using scenes for lights, with the Hue natural light scene. Should I just let it like that ?

Edit: Sorry I just read it was not working with scenes.

Edit 2 : The way Dynamic lighting works is the contrary of what I have now, the darker it gets the more light/brightness you get, while with hue natural lighting for example the later in the evening, the less light you get.

Blockquote

Now when you push the button it should turn ON this new sensor in every group turning ON all your lights or keeping them ON and only when the total room motion detection goes OFF then this sensor will go OFF and your lights will turn OFF :wink: Nice hay :partying_face: No need for by-pass and your two automationsā€¦ you only need this temple sensor. :tada:

==== > The issue I have now with the above is that if I push the button, finish what I need to do with all the lights on, and turn off the lights, without leaving the room, the following happens :slight_smile:

  • Lights turn on again, as presence is still detected everywhere.
  • I have to press a second time to make it turn off.
  • I canā€™t just go to sleep and make the FP2 work again if I wake up at night, lights stay off. I have to quit the room to make the new sensor turn off, and fp2 working again as usual.

In basic scenario, the sensor turns my switch ON, and then the switch turns off after a delay, right,? Basically what I need, is so that manual switching ON also has same delay as if sensor detected motion, and so that if motion is still detected the light will not turn OFF.

I think I can use By-pass, but then I will not have a regular by-pass (like when I need it to stay on for longer time), and it will turn OFF after the set period of time anyways, even if the motion is detected, right?

Blacky, Iā€™m a bit confused about ambient light.

I have the following situation. I want to turn a light on with motion any time of day for 30 seconds from last motion, but only if the ambient light is below a certain level, letā€™s say 30. No night light option, no sun elevation. Also there is a bypass off when I set a boolean helper to nighttime.

But what does the ambient high value of 80 do? Does the light not turn OFF when motion is no longer detected? Why is there a needs for a high value?

alias: Front Hall Light on with Motion & Lumens
description: Front Hall Light on with Motion & Lumens
use_blueprint:
  path: Blackshome/sensor-light.yaml
  input:
    motion_trigger:
      - binary_sensor.front_hall_motion_and_occupancy_sensor_for_light
    light_switch:
      entity_id: light.front_door_dimmer_switch_z_wave
    time_delay: 0.5
    include_light_control:
      - use_brightness
      - use_transition
    light_brightness: 75
    light_transition_on: 1
    light_transition_off: 1
    include_night_lights: night_lights_disabled
    include_night_light_control:
      - use_brightness
      - use_transition
    night_light_transition_on: 1.5
    night_light_transition_off: 1.5
    night_lights_conditions: []
    night_time_delay: 3
    include_sun: sun_disabled
    night_lights_sun_elevation: -3
    include_ambient: ambient_enabled
    ambient_light_sensor: sensor.front_hall_motion_and_presence_sensor_illuminance
    ambient_light_options: ambient_light_option_disabled
    ambient_light_value: 30
    include_bypass:
      - bypass_enabled
      - bypass_enabled_stop
    include_time: time_disabled
    night_light_brightness: 20
    sun_elevation: -1.5
    motion_bypass:
      - input_boolean.day_night_mode
    motion_bypass_lights_stop:
      - input_boolean.day_night_mode
    after_time: "17:00:00"
    before_time: "07:00:00"
    sun_elevation_rising: -4
    ambient_light_high_value: 80