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

@danielo515

Yes try to copy and past the id in to be sure you have the correct one. You could also try to and select in ambient NO - My Ambient Light Sensor is not affected by the Lights. Then when your light turns ON make sure your Ambient Light - High Lux Value is above your lux sensor reading + sum.

Blacky :grinning:

Thanks for the input.

So i think maybe i confused you or maybe i am just not following what you said, probably the later lol.

Here are the sensors i have in play for this room:

  1. garage house door sensor
  2. garage door sensor
  3. motion sensor 1
  4. motion sensor 2
  5. Garage Lights Times of day Sensor (Helper on from 11a-6p)

Groups in use:

  1. Garage Door Group - Any On (either door being open turns the group on - Sensor 1 and 2)
  2. Garage Motion Group - Any On (either motion active turns the group on - Sensor 3 and 4)
  3. Garage Motion Group - All On (group is on only if both motions are active - Sensor 3 and 4)

Group 2 is what i am calling my Occupancy sensor and is not used in the triggers as i do not want a single motion to turn on the lights.

Triggers In use:

  1. Garage Door Group - Any On
  2. Garage Motion Group - All On
  3. Garage Lights Times of day Sensor

Maybe I’m using the wrong terms. For what i am calling occupancy sensor (group 2), i want to use it to only keep the lights On that were already turned on by the existing triggers in the original blueprint.

That’s really the only change or addition i really need to figure out.

I have the lights working as far as turning on and off with the extra (off) lights included just fine, though having the extra lights come back on within a set time would be nice option to have.

I thought about the bypass but the problem with the bypass is if this sensor is active when i come into the room by opening the door or similar, it keeps the entire automation from running. I was trying the Bypass option 3.

I didn’t want to use option 1 as i didn’t want my ā€œoccupancyā€ sensor to turn anything on.

Blockquote
What you need is to group all three + occupancy sensor into one trigger group (a binary sensor group):

  1. Add your two door sensors. (not the group)
  2. Add your motion group (if this is what works for your birds, use the group rather than the individual motion sensors). If I got this wrong whatever you have that works for your motion sensors.
  3. Add your schedule (this must be a binary sensor so it can be added to the group as shown above).
  4. The new occupancy sensor.

I understand what you are telling me to do to make a group.

What i am not following is, how this new group …

I think i just had an epiphany?

I’ve been reading and re-reading as i have been typing and i think i might have just understood what you were saying.

Are you saying when i group as you mentioned, the occupancy sensor will not trigger the lights on because the bee in the hive method requires the door to open first?

So it would not trigger until its occupied right?

I would have this group setup so that any of the entities being on would make the group be on correct?

I think that would work and take care of all my needs.

It would be very nice if this could be added into this blueprint at some point. It would make this easier, or at least more obvious.

Or maybe you could document this scenario and add it into the instructions or description for now.

I still want to work on adding the occupancy into this. Right now when i turn my addition on, it goes into a loop that matches the timer. Ill message you directly on this.

@Blacky

Apparently i can not figure out how to message you direct?

1 Like

Hi Blacky - sorry, wasn’t able to reply sooner but your suggestion about entities worked! Thanks

1 Like

Hi,

I’m having a bit of an issue (i’m not sure if maybe its’s a bug or i’m doing something wrong).

Here’s my setup: (Unfortunately, because i’m ā€œnewā€ I can’t put screenshots in my response)

Physical setup:

  1. one thirdreality zigbee light in the washroom
  2. one thirdreality motion, lux sensor night light in master bedroom next to the washroom

What I wanted:

When the occupancy sensor on the thirdreality night light triggers to occupied + it’s night time + the thirdreality washroom light bulb is currently off (will play with lux sensor values later), the washroom light turns on for x seconds

What I setup in ā€œSensor Lightā€ blueprint:

Trigger:
FL1 Master BDR night lightt (2MQ)

Lights:
FLR1: Master WR 1 (HA LG)
FLR1: Master BDR 1 (HA LG)
Time Delay: 1 minute (for testing)

Sun Elevation:
Enable the sun option: checked off
Sun Elevation Falling: -1.5 degrees (default)
Sun Elevation Rising: -4 degrees (default)

State control:
Enable State Control Option: checked off
Activation State: OFF state checked off
Control entity: FL1: Master WR 1 (HA LG)

I’m also using adaptive lighting integration to change light values based on sun/day if that’s relevant.

My issue is:

After adding the ā€œState controlā€ section, the washroom light and night light constantly alternate turning off and on until I disable the automation.

Please help and love the blueprint!

Thank you

@mallison01

This is not good to have all 3 triggers. We need to group this into one group and then use that group as the trigger.

Let’s start here first.

Create a group helper, for this example and for our reference lets call it Garage Trigger Group…

  1. Go to Settings > Devices & Services > Helpers.
  2. Click ā€œ+ Create Helperā€ and choose Group > Binary sensor group.
  3. Set a Name for your new binary sensor group Garage Trigger Group.
  4. Add the following members;
    • Garage house door sensor
    • Garage door sensor
    • Garage Motion Group - All On
    • Garage Lights Times of day Sensor
  5. Click Submit.

Now remove all your triggers from Trigger Sensor - Binary Sensors - Schedule and add only one trigger Garage Trigger Group.

Now the automation will work correctly and trigger when

  1. Any door is open
  2. Garage Motion Group - All On
  3. Garage Lights Times of day Sensor

Now your ā€œoccupancyā€ sensor.

You would like

So for this we could say

If the Primary light is ON and any motion detected the occupancy sensor = ON.

NOTE: Depending on your birds triggering a motion sensor when the light is ON may keep it ON, but you know best so let’s work with this. You may decide to just use one motion sensor where your birds don’t trigger it but you will need to work this out. Note - I don’t think this will work well but try and see what happens.

For this we will create a new template binary sensor for what you call your ā€œoccupancyā€ sensor.

  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. For this example let’s call it Garage Occupancy Sensor
  4. In the State template field, paste the code below.
    Replace light.your_primary_light with the actual entity ID of your light.
    Replace binary_sensor.motion1 & binary_sensor.motion2 with the actual entity ID of your motion sensors.
  5. Set the Device class if you want this binary sensor to behave like a occupancy sensor, set occupancy.
  6. Optionally, select a Device to link this sensor to. Leave it blank if not needed.
{{ is_state('light.your_primary_light', 'on') and (
 is_state('binary_sensor.motion1', 'on') or
 is_state('binary_sensor.motion2', 'on')
) }}

Now you have what you call occupancy sensor.

All we need to do now is add this Garage Occupancy Sensor to the Garage Trigger Group.

If you unsure how to do this see this FAQ click here

Then in your Garage Trigger Group you will have the following members.

  • Garage house door sensor
  • Garage door sensor
  • Garage Motion Group - All On
  • Garage Lights Times of day Sensor
  • Garage Occupancy Sensor

That is it your all done :partying_face: Test it out and see if it works for you!

I think it wont work well but test it out and see. I would use the bee in the hive sensor. See if your doors are open then the trigger will be ON you only need something when the doors are closed and you trigger your Garage Motion Group - All On. Then we know your in the garage.


Now if you find that your Garage Occupancy Sensor doesn’t work like it should try creating a :honeybee: Bee In The Hive :honeybee: Template Binary Sensor, click here

Door Group: Any door open = ON & all doors closed = OFF.
Garage Motion Group - All On: Both motion sensors ON = ON & any motion sensor OFF = OFF.

So you could use the :honeybee: Bee In The Hive :honeybee: blueprint and then use the toggle helper (toggle helper you have in the bee in the hive blueprint) in bypass option 1 (click here) or you could create a template binary sensor (click here) and add it to the Garage Trigger Group.

For this you would use your Door Group as your door because you have 2 doors. And for your motion sensor you would use your Garage Motion Group - All On. Then if your doors are closed and your Garage Motion Group - All On turns ON it will turn ON the :honeybee: Bee In The Hive :honeybee: Template Binary Sensor. When you open the door to leave it will turn it OFF. So it only works when the doors are closed and it detects motion when your 2 motion sensor are ON because your using the Garage Motion Group - All On. It then knows your in the garage and until you open a door to leave it will stay ON. A true occupancy sensor.

If you use the blueprint, use the toggle helper in bypass option 1 and your Garage Trigger Group to the following members.

  • Garage house door sensor
  • Garage door sensor
  • Garage Motion Group - All On
  • Garage Lights Times of day Sensor

If you create this template binary sensor you will then modify your Garage Trigger Group to the following members.

  • Garage house door sensor
  • Garage door sensor
  • Garage Motion Group - All On
  • Garage Lights Times of day Sensor
  • Garage Occupancy Sensor - Bee In The Hive

Let us know if this helps/works for you.

Blacky :grinning:

@HomeAssistantLover18

Could you please provide us your YAML of the automation? This YAML code are the settings you have selected in the automation so I can help. To do this go into your automation, top right 3 dots, Edit in YAML, copy all the code, come back to the forum and in your reply at the top tool bar click on ā€œ</>ā€ and paste code in there.

Blacky :grinning:

Hi Blacky,

Absolutely! Thanks so much for your response!

Here is the YAML code:

alias: Sensor Light test
description: ""
use_blueprint:
  path: Blackshome/sensor-light.yaml
  input:
    motion_trigger:
      - binary_sensor.fl1_master_bdr_night_light_2mq_occupancy
    light_switch:
      entity_id:
        - light.fl1_master_wr_1_ha_lg
        - light.fl1_master_bdr_1_ha_lg
    time_delay: 12.5
    include_night_lights: night_lights_disabled
    night_lights_conditions:
      - sun_enabled
    include_sun: sun_enabled
    include_state_control: state_control_enabled
    state_control_entity: light.fl1_master_wr_1_ha_lg
    include_bypass: []
    motion_bypass_lights_stop: []
    motion_bypass_lights_off: []
    motion_bypass_lights_on: []
    state_control_activation_state: "off"

Thank you!

@HomeAssistantLover18

Thanks that makes it easier to help.

In the State Control you don’t use the light in there and is why it is turning ON and OFF. See the automation can only work when the light is OFF so when it OFF the automation turns it ON but then it can only work when the light is OFF so the automation turns the light OFF but it works when the light is OFF so the automation turn the light ON but… and on and on it goes.

Remove your light from State Control and disable this option. Make sure you remove the light from State Control so it wont trigger in the background and be stopped. Like this

alias: Sensor Light test
description: ""
use_blueprint:
  path: Blackshome/sensor-light.yaml
  input:
    motion_trigger:
      - binary_sensor.fl1_master_bdr_night_light_2mq_occupancy
    light_switch:
      entity_id:
        - light.fl1_master_wr_1_ha_lg
        - light.fl1_master_bdr_1_ha_lg
    time_delay: 12.5
    include_night_lights: night_lights_disabled
    night_lights_conditions:
      - sun_enabled
    include_sun: sun_enabled
    include_state_control: state_control_disabled
    include_bypass: []
    motion_bypass_lights_stop: []
    motion_bypass_lights_off: []
    motion_bypass_lights_on: []
    state_control_activation_state: "off"

It will then work just fine.

Blacky :grinning:

Copi pasted it…
And see what stupid difference it was:

I don’t know how that got there…

Thank you very much Blacky! I disabled the state control now and it’s working like it should now.

My only question is:

Does your blueprint have any sort of ā€œblocking automationā€ feature (like this one: Motion/Occupancy-activated Light Blueprint for Home Assistant)?

It has a small blocking section that allows you to select the entity (such as the light) and type in the state such as ā€œonā€ and it seemed to work for me.

This way, for example, if the washroom light was already on (someone manually turned on the light, for example); the automation wouldn’t trigger. This made it so if I turned on the washroom light myself manually (like through the HA app), the automation wouldn’t trigger thus not taking over the washroom light, and turning it off when the timer reached your set amount of seconds (so if I turned the light on manually and I was in the shower for example, it wouldn’t turn the light off on me because someone walked past the motion sensor in the bedroom which made the automation trigger).

Thank you!

@danielo515

Well that was a good find. Nice to know it working now.

Blacky :grinning:

@HomeAssistantLover18

All that does is stop the automation from running. So if you had it set like that when the automation triggered it would also stop and you would have the time delay to then turn OFF like a 1 shot.

It would be the same if you put the light in bypass option 1 but I wouldn’t recommend that. You could use a toggle helper if you like in option 1 and then use the bypass auto OFF in X time. Turn ON the toggle helper that turns ON the light keeping it ON and then it turns the toggle helper OFF for you that will turn the light OFF if the motion sensor is clear or once it becomes clear so your not in the dark.

So I have a :shower: Bathroom Humidity Exhaust Fan blueprint that has an automation link. I use that when having a shower and it keeps the lights ON. You should be able to get everything working perfectly.

I also have a :stop_button: Manual Control Status Tracker blueprint that you can use so if you manually turn ON the light in the UI or by the switch it will toggle a toggle helper and you then use that in the bypass not the light. It also has a auto OFF for you.

Blacky :grinning:

Thank you very much Blacky! I’ll take a look at those links!!

I think i have it working now.

When i listed the triggers in use, i should have specified that the Garage motion group any on was not a trigger listed in the blueprint and was only being used to try to keep the lights on when they were already on.

What i ended up doing was creating a group:

Garage Lighting Automation Sensor Group with the following members:

  1. Garage Bird Lights Time of day sensor
  2. Garage Door Sensor
  3. Garage House Door Sensor
  4. Garage Motion Sensor Group - All On
  5. Garage Occupancy Sensor ( new sensor made based off of your bee in the hive yaml)

Any one of these being active will make the group turn On.

For the New Occupancy Sensor i did the following so that when the automation runs, it turns on another switch that enables the occupancy sensor.

I created a Input Boolean helper first then used the following yaml in my templates.yaml

# Garage Occupancy Sensor
- trigger:
    - trigger: state
      entity_id: binary_sensor.garage_motion_sensor_group_any_on
      to: "on"
    - trigger: state
      entity_id: binary_sensor.garage_motion_sensor_group_any_on
      to: "off"
      for:
        seconds: 30
    - trigger: state
      entity_id: input_boolean.garage_occupancy_enable
    - trigger: homeassistant
      event: start
  

- switch:
    - name: "Garage Occupancy Enable"
      unique_id: "garage_occupancy_enable_switch"
      state: "{{ is_state('input_boolean.garage_occupancy_enable_helper', 'on') }}"
      turn_on:
        service: input_boolean.turn_on
        target:
          entity_id: input_boolean.garage_occupancy_enable_helper
      turn_off:
        service: input_boolean.turn_off
        target:
          entity_id: input_boolean.garage_occupancy_enable_helper

  
  binary_sensor:
    - name: "Garage Occupancy Sensor"
      unique_id: "garage_occupancy_sensor"
      device_class: occupancy
      icon: mdi:account-box-outline
      state: >
        {{ is_state('input_boolean.garage_occupancy_enable', 'on') and 
           is_state('binary_sensor.garage_motion_sensor_group_any_on', 'on') }}

The input boolean and the switch stay synced and then i can use the switch in your blueprint without modification and this occupancy sensor now works only when the enable switch is on, which is turned on and off by the automation.

And yes on occasion the birds will keep the occupancy on, but its pretty rare and normally only lasts one cycle.

I think this will cover most cases of the garage lighting.

I need to think about what happens if someone manually turns the light on or off and when that happens it should still turn the lights off after time runs out but only if its not during the Bird lights schedule.

Also if someone does accidentally turns the lights off while they should be on for the birds, i want them to come back on.

I have a similar scenario in my kitchen and bathrooms using this same blueprint i need to think through.

The guest bathroom does not have a window and will be pretty simple to figure out i think.

But the kitchen and master bathroom have windows and i use the ambient light sensor from my weather station to determine if the lights should come on.

Both rooms have motion and door sensors.

But i see when doing that if i turn them on manually, they do not automatically turn off.

I think i can take what i came up with here and apply some of the same logic to these rooms and move the ambient sensor and a manual switch press from these into the triggers.

Unless there is a better way to do this?

Maybe ideas for future features of your blueprint. This blueprint almost does everything i need coming from Hubitat and using the room lighting app.

Maybe if there was a separate set of triggers that only turn off the automation.
Maybe an option to have the ambient sensor or device tracker only keep the automation from turning lights on, that way if it was turned on manually the rest of the automation would run to turn them off.

Id be happy to help and test it all, but trying to modify your blueprint myself is proving to be difficult for me.

EDIT: I have seen your Manual Control status tracker and have messed with it some. I am thinking i would use this combined with the bypass options for my bathrooms and kitchen.

I do not think it will be that simple for the garage.

@mallison01

I think you’re definitely on the right track now. Using template sensors is a really nice way to control your automations, as they give you the flexibility to adjust or change things easily to suit your needs. For example, you might have one template that works well in one room and a completely different one in another, and the blueprint allows you to include them either way. I also rely on templates myself, I find it much easier to maintain just one blueprint and then use small snippets to customize it for different situations.

In your garage, I would personally use the Bee in the Hive sensor as it is, but since I don’t know the exact layout, you’re really the best one to decide what will work best for your setup. With your birds around, a safety beam might actually be a better option than a motion sensor.

I’m really glad to hear you’ve got it working now!

Blacky :grinning:

Hi @Blacky !

Thanks for your work on this blueprint – it ran into a recurring error that seems to originate from the automation it generates.

Here’s the log excerpt from Home Assistant:

Logger: homeassistant.components.automation.hallway  
Source: components/automation/__init__.py:738  
Integration: Automation  
First occurred: 08:09:50 (12 occurrences)  
Last logged: 19:40:34  

Error while executing automation automation.couloir: TypeError: unhashable type: 'list'

It looks like somewhere in the blueprint or the resulting automation, a list is being used in a context that expects a hashable type (like a string or tuple).

Could you take a look or let me know if there’s something I should adjust in the inputs? Happy to share more details if needed.

alias: Hallway
description: ""
use_blueprint:
  path: Blackshome/sensor-light.yaml
  input:
    motion_trigger:
      - binary_sensor.motion_hallway_occupation
    light_switch:
      entity_id: light.hallway
    time_delay: 0.15
    end_scenes: []
    include_light_control:
      - use_transition
    include_ambient: ambient_enabled
    ambient_light_sensor: sensor.motion_hallway_eclairement
    ambient_light_value: 8
    ambient_light_high_value: 50
    ambient_light_options: ambient_light_option_enabled
    include_night_lights: night_lights_enabled
    night_lights_conditions:
      - entity_state_enabled
    night_lights:
      entity_id:
        - light.hallway
    night_boolean_scenes_scripts: input_boolean.hallway_night
    night_time_delay: 1
    include_night_light_control:
      - use_brightness
      - use_transition
      - if_lights_are_on_adjust_when_crossing_over
    night_light_transition_on: 2
    night_light_transition_off: 4
    night_light_brightness: 15
    include_dynamic_lighting: enable_sun_elevation_colour_lux_brightness
    dynamic_lighting_boolean: input_boolean.hallway
    light_transition_off: 4
    light_transition_on: 0.5
    include_night_light_colour_control: use_colour_temperature
    night_light_colour_temperature: 2500
    dynamic_lighting_min_lux: 10
    dynamic_lighting_max_lux: 150
    include_night_glow: night_glow_disabled
    light_brightness: 100
    dynamic_lighting_step_value: 4
    include_bypass: []
    night_glow_light_brightness: 15
    include_night_glow_light_control: []
    motion_bypass_lights_stop:
      - input_boolean.toggle_wake_up_process_runing
    bypass_time_delay: 2
    night_lights_entity_state:
      - binary_sensor.toggle_night_helper
    motion_bypass_lights_on: []
    dynamic_lighting_min_brightness: 60

Maybe, this other one could help:

Enregistreur: homeassistant.components.automation.hallway
Source: helpers/script.py:2067
intégration: Automatisation (documentation, problèmes)
S'est produit pour la premiĆØre fois: 09:49:47 (21 occurrences)
Dernier enregistrement: 10:04:56

hallway: Choose at step 1: default: Parallel actions for dynamic lighting and normal lights: parallel 1: Choose at step 10: 8 - Dynamic Lighting - Sun Elevation Lighting - Colour Temp + Lux Controlled Brightness: Parallel actions for dynamic lighting: parallel 1: Error executing script. Error rendering template for repeat at pos 1: TypeError: unhashable type: 'list'
hallway: Choose at step 1: default: Parallel actions for dynamic lighting and normal lights: parallel 1: Choose at step 10: 8 - Dynamic Lighting - Sun Elevation Lighting - Colour Temp + Lux Controlled Brightness: Error executing script. Error rendering template for parallel at pos 1: TypeError: unhashable type: 'list'
hallway: Choose at step 1: default: Parallel actions for dynamic lighting and normal lights: parallel 1: Error executing script. Error rendering template for choose at pos 10: TypeError: unhashable type: 'list'
hallway: Choose at step 1: default: Error executing script. Error rendering template for parallel at pos 4: TypeError: unhashable type: 'list'
hallway: Error executing script. Error rendering template for choose at pos 1: TypeError: unhashable type: 'list'

@Hugoliv

Hi Olivier, thanks for all the info that helps me.

In Dynamic Lighting you selected option 8. In Dynamic Lighting - Ambient Light Sensor you will need to add your lux sensor.

I also see you are using Ambient. This will conflict with DL because your Low Lux Value is set to 8. That means this automation will not run until your lux value is below 8. In DL you have a Max Lux Value of 150 with a Min Lux Value of 10. Remember you also using sun elevation and at 15 your lux value will probably be way higher than 150.

I made some adjustments adding in your lux sensor into DL and adjusted your ambient to 150 and 200. This will get you going so you can make adjustments. Your automation will now run when lux is below 150 and your DL will start adjusting it. You may decide to adjust your Ambient Light - Low Lux Value to 200 +. Remember the Ambient Light - Low Lux Value is a global condition and the value set is when the lux is below your set point then the automation can run. DL lux values are the points it will start changing brightness.

alias: Hallway
description: ""
use_blueprint:
  path: Blackshome/sensor-light.yaml
  input:
    motion_trigger:
      - binary_sensor.motion_hallway_occupation
    light_switch:
      entity_id: light.hallway
    time_delay: 0.15
    end_scenes: []
    include_light_control:
      - use_transition
    include_ambient: ambient_enabled
    ambient_light_sensor: sensor.motion_hallway_eclairement
    ambient_light_value: 150
    ambient_light_high_value: 200
    ambient_light_options: ambient_light_option_enabled
    include_night_lights: night_lights_enabled
    night_lights_conditions:
      - entity_state_enabled
    night_lights:
      entity_id:
        - light.hallway
    night_boolean_scenes_scripts: input_boolean.hallway_night
    night_time_delay: 1
    include_night_light_control:
      - use_brightness
      - use_transition
      - if_lights_are_on_adjust_when_crossing_over
    night_light_transition_on: 2
    night_light_transition_off: 4
    night_light_brightness: 15
    include_dynamic_lighting: enable_sun_elevation_colour_lux_brightness
    dynamic_lighting_boolean: input_boolean.hallway
    light_transition_off: 4
    light_transition_on: 0.5
    include_night_light_colour_control: use_colour_temperature
    night_light_colour_temperature: 2500
    dynamic_lighting_min_lux: 10
    dynamic_lighting_max_lux: 150
    include_night_glow: night_glow_disabled
    light_brightness: 100
    dynamic_lighting_step_value: 4
    include_bypass: []
    night_glow_light_brightness: 15
    include_night_glow_light_control: []
    motion_bypass_lights_stop:
      - input_boolean.toggle_wake_up_process_runing
    bypass_time_delay: 2
    night_lights_entity_state:
      - binary_sensor.toggle_night_helper
    motion_bypass_lights_on: []
    dynamic_lighting_min_brightness: 60
    dynamic_lighting_lux_sensor: sensor.motion_hallway_eclairement

Blacky :grinning:

@Blacky

Thank you very much ! Ah, I forgot the lux sensor, my bad.

1 Like