♾ Sensor Light Add On - Media & Movie Lights - House Alarm Lights - Smoke Alarm Lights & Exhaust Fans + More

@kobejo34

Have you put the script into Lights - Switches - Scenes - Scripts? If you use the light entity and use Transition - ON will that work?

Blacky :grinning:

Like this?

@kobejo34

Seems like you’re using a scene, not a script, that’s probably why it looks like the script isn’t working. Swap it out for the script and give it another try :wink:

Blacky :grinning:

Hi @Blacky ,
First of all great blueprint. But it appears it doesn´t work for me. :sob:

I´ve checked everything. The YAML and all that and it seems it´s correctly setup or I´m missing something terribly obvious. The automation simply doesn´t trigger.

Platform of the media player is Amazon Fire TV Cube.
I double checked and even added all possible media player combinations but the automation never triggers. I can see the media_player indicating the status of “Playing” but nothing.

Here´s my yaml

alias: Movie Night Plex
description: ""
use_blueprint:
  path: Blackshome/sensor-light-add-on.yaml
  input:
    trigger_entities:
      - media_player.fire_tv
      - media_player.plex_plex_for_android_tv_aftgazl
    trigger_on_state:
      - playing
      - "on"
      - Playing
    app_attribute: []
    trigger_off_state:
      - paused
      - idle
      - standby
      - "off"
    off_include_light_control:
      - use_transition
    off_light_switch:
      entity_id:
        - light.gaming_room_pc
        - light.living_room_ceiling_back
        - light.hue_lightstrip_plus_1_2
        - light.smart_curtains
    include_end_turn_on: enable_end_turn_on
    end_snapshot_name: lights_before_movies
    end_light_switch:
      entity_id:
        - light.gaming_room_pc
        - light.living_room_ceiling_back
        - light.hue_lightstrip_plus_1_2
        - light.smart_curtains
    end_include_light_control:
      - use_transition
    intermission_light_switch:
      entity_id:
        - light.smart_curtains
        - light.hue_lightstrip_plus_1_2
        - light.living_room_ceiling_back
    intermission_include_light_control:
      - use_transition
    include_start_turn_off: enable_start_turn_off
    include_intermission: intermission_enable

Can you give me some feedback on what might be wrong?
Really appreciate your time.
Thank you.

@jfplopes

Just quickly looking at it (sorry big day today) you have no Movie Lights. Just add a light in light.hue_lightstrip_plus_1_2 and set it to 0% brightness (that will turn it OFF).

Let us know how you go. Like this… I have also changed your Intermission Lights and Lights ON at End so you can see how it works. Adjust as required.

alias: Movie Night Plex
description: ""
use_blueprint:
  path: Blackshome/sensor-light-add-on.yaml
  input:
    trigger_entities:
      - media_player.fire_tv
      - media_player.plex_plex_for_android_tv_aftgazl
    trigger_on_state:
      - playing
      - "on"
      - Playing
    app_attribute: []
    trigger_off_state:
      - paused
      - idle
      - standby
      - "off"
    off_include_light_control:
      - use_transition
    off_light_switch:
      entity_id:
        - light.gaming_room_pc
        - light.living_room_ceiling_back
        - light.smart_curtains
    include_end_turn_on: enable_end_turn_on
    end_snapshot_name: lights_before_movies
    end_light_switch:
      entity_id:
        - light.gaming_room_pc
        - light.living_room_ceiling_back
        - light.hue_lightstrip_plus_1_2
        - light.smart_curtains
    end_include_light_control:
      - use_transition
      - use_brightness
    intermission_light_switch:
      entity_id:
        - light.smart_curtains
        - light.hue_lightstrip_plus_1_2
        - light.living_room_ceiling_back
    intermission_include_light_control:
      - use_transition
      - use_brightness
    include_start_turn_off: enable_start_turn_off
    include_intermission: intermission_enable
    light_switch:
      entity_id: light.hue_lightstrip_plus_1_2
    include_light_control:
      - use_brightness
    light_brightness: 0
    intermission_light_brightness: 20

Blacky :grinning:

Thank you @Blacky . That was the issue.

A minor feedback regarding the app selection. There are two options available. One for Chromecast and another for Apple TV. In my case I’m using Plex on Fire TV Cube. For Fire TV Cube I used the application name “com.plexapp.android”.

With that said, marvelous automation blueprint. Thank you again for your help and this fine blueprint.
Here’s my updated config:

alias: Movie Night Plex
description: ""
use_blueprint:
  path: Blackshome/sensor-light-add-on.yaml
  input:
    trigger_entities:
      - media_player.fire_tv
    trigger_on_state:
      - playing
    app_attribute:
      - com.plexapp.android
    trigger_off_state:
      - standby
      - "off"
      - idle
      - paused
      - unavailable
    off_include_light_control: []
    off_light_switch:
      entity_id:
        - light.gaming_room_pc
        - light.living_room_ceiling_back
        - light.hue_lightstrip_plus_1_2
        - light.smart_curtains
        - light.nanoleaf_light_panels_59_c9_f3
        - switch.living_room_motion_sensor_motion_sensor_enabled
    include_end_turn_on: enable_end_turn_on_snapshot
    end_snapshot_name: lights_before_movies
    end_light_switch:
      entity_id:
        - light.gaming_room_pc
        - light.living_room_ceiling_back
        - light.hue_lightstrip_plus_1_2
        - light.smart_curtains
        - switch.living_room_motion_sensor_motion_sensor_enabled
        - light.nanoleaf_light_panels_59_c9_f3
    end_include_light_control: []
    intermission_light_switch:
      entity_id:
        - light.smart_curtains
        - light.hue_lightstrip_plus_1_2
        - light.living_room_ceiling_back
        - light.nanoleaf_light_panels_59_c9_f3
    intermission_include_light_control: []
    include_start_turn_off: enable_start_turn_off
    include_intermission: intermission_enable
    light_switch:
      entity_id: light.hue_color_spot_6
    include_light_control: []
    off_light_transition_off: 3
    end_snapshot_helper: input_boolean.light_before_movies
    intermission_state:
      - paused
      - idle

Omg I feel like such an idiot. well I selected the right one that was really a posting mistake as I tried a lot of stuff. I copied the blueprint and the only way I can get it to work is like this.

action: script.ashley_s_light_fader
data:
light: light.family_lamps
lampBrightnessScale: zeroToTwoFiftyFive
transitionTime:
hours: 0
minutes: 0
seconds: 30
easingTypeInput: easeInOutSine
endBrightnessPercent: 5
endBrightnessEntityScale: zeroToTwoFiftyFive
autoCancelThreshold: 10
shouldStopIfTheLampIsTurnedOffDuringTheFade: true
shouldResetTheStopEntityToOffAtStart: false
shouldInvertTheValueOfTheStopEntity: false
minimumStepDelayInMilliseconds: 100
shouldTryToUseNativeLampTransitionsToo: true
isDebugMode: false

Ok I got it to work by having a script call the main script which is what I think you said.

1 Like

@jfplopes

Thanks for the update… glad you are up and running.

Blacky :grinning:

I’m struggling a lot to get this to turn off my lights when I want to watch a movie. It looks like my SHIELD uses the “playing” as a trigger state, but it doesn’t turn off the lights. Can anyone help?

alias: Sensor Light Add On
description: ""
use_blueprint:
  path: Blackshome/sensor-light-add-on.yaml
  input:
    light_brightness: 69
    include_end_turn_on: disable_end_turn_on
    end_light_switch:
      entity_id:
        - light.bedroom_2
        - light.living_room
        - light.kitchen
        - light.hallway
    include_automation_link: disable_automation_link
    automation_link: []
    include_start_turn_off: enable_start_turn_off
    off_light_switch:
      entity_id:
        - light.hallway
        - light.living_room
        - light.kitchen
        - light.bedroom_2
    trigger_entities:
      - media_player.shield_3
      - media_player.v24d
      - media_player.shield_2
      - media_player.shield
      - media_player.lg_webos_tv_oled65b8pla
    trigger_off_state:
      - standby
      - "off"
    trigger_on_state:
      - playing
    include_intermission: intermission_disable
    include_automation_link_time_delay: disable_time_delay
    automation_link_time_delay: 3.5
    off_light_transition_off: 5
    intermission_state: []
    end_light_brightness: 70
    end_light_transition_on: 3

Edit, I did some changes which I think have fixed it. Need to test tomorrow

alias: Sensor Light Add On
description: ""
use_blueprint:
  path: Blackshome/sensor-light-add-on.yaml
  input:
    light_brightness: 69
    include_end_turn_on: enable_end_turn_on
    end_light_switch:
      entity_id:
        - light.bedroom_2
        - light.living_room
        - light.kitchen
        - light.hallway
    include_automation_link: disable_automation_link
    automation_link: []
    include_start_turn_off: enable_start_turn_off
    off_light_switch:
      entity_id:
        - light.hallway
        - light.living_room
        - light.kitchen
        - light.bedroom_2
    trigger_entities:
      - media_player.shield_3
      - media_player.shield_2
      - media_player.shield
      - media_player.lg_webos_tv_oled65b8pla
    trigger_off_state:
      - standby
      - "off"
    trigger_on_state:
      - playing
      - Playing
      - "on"
    include_intermission: intermission_disable
    include_automation_link_time_delay: disable_time_delay
    automation_link_time_delay: 3.5
    off_light_transition_off: 5
    intermission_state: []
    end_light_brightness: 70
    end_light_transition_on: 3
    app_attribute:
      - org.jellyfin.androidtv
      - Jellyfin
    light_switch:
      entity_id:
        - light.hallway
        - light.living_room
        - light.kitchen
        - light.bedroom_2

@klovnious

Close! Here’s how it works:

The Movie Lights option must include at least one light. If you’d like a light to remain OFF during movie mode, simply set its brightness to 0%.

In this example, I chose the kitchen lights as they’re most likely to support brightness control. If yours don’t, just replace them with another light that does.

Also, take note that I’ve selected the brightness option to allow this control.

Your YAML below.

alias: Sensor Light Add On
description: ""
use_blueprint:
  path: Blackshome/sensor-light-add-on.yaml
  input:
    light_brightness: 0
    include_end_turn_on: enable_end_turn_on
    end_light_switch:
      entity_id:
        - light.bedroom_2
        - light.living_room
        - light.kitchen
        - light.hallway
    include_automation_link: disable_automation_link
    automation_link: []
    include_start_turn_off: enable_start_turn_off
    off_light_switch:
      entity_id:
        - light.hallway
        - light.living_room
        - light.bedroom_2
    trigger_entities:
      - media_player.shield_3
      - media_player.shield_2
      - media_player.shield
      - media_player.lg_webos_tv_oled65b8pla
    trigger_off_state:
      - standby
      - "off"
    trigger_on_state:
      - playing
      - Playing
      - "on"
    include_intermission: intermission_disable
    include_automation_link_time_delay: disable_time_delay
    automation_link_time_delay: 3.5
    off_light_transition_off: 5
    intermission_state: []
    end_light_brightness: 70
    end_light_transition_on: 3
    app_attribute:
      - org.jellyfin.androidtv
      - Jellyfin
    light_switch:
      entity_id:
        - light.kitchen
    end_include_light_control:
      - use_brightness
    include_light_control:
      - use_brightness

Blacky :grinning:

When trying to do a home assistant automation using this blueprint I got the error: "Error rendering variables: UndefinedError: ‘list object’ has no attribute ‘entity_id’

Changed default: to default: {} for light entities after googling about similar problems.

Now the script renders and works as intended for me.

@Sakakidash

You can also add a light entity in and set the brightness to 0. This way it will also turn OFF.

Blacky :grinning:

I also get the same error with this automation but don’t really understand the solution you’ve posted - any chance you can elaborate please?

Error rendering variables: UndefinedError: ‘list object’ has no attribute ‘entity_id’

My lights are turning on to “on” or playing levels due to sun elevation trigger even if my trigger is not in an “On” state (i.e. my lights are turning on when the TV is off and media paused). Is this intended function? I suppose paused is the intermission option, but AppleTV stays paused forever even with the TV off. I only want the initial turn on to occur if motion is detected per my linked Sensor light automation or if the media player is in “on” state (playing).

If I turn the light off, it also does not turn on with motion until I start playing something on the media player.

Thanks for your hard work on these blueprints!

@koconut

It has been a while since I looked at the code but my thinking is if your using sun elevation and it triggers on this… and you are using intermission and your AppleTV is paused… then it thinks your using it and it starts as per what your asking it to do.

Can you have it so if your TV is OFF then it will also turn your AppleTV off?

Blacky :grinning:

@Blacky
Can I use this Blueprint for next situation:
I have a RGB light which is controlled by Sensor light. And I have a CO2 meter which gave integer output to HA.
I want when CO2 level is above 2000ppm light change to red and flash for 10 sec and then goes back like was before that action and do that until level of CO2 is beyond 2000. Can I make template helper which will trigger this automation and what to set in blueprint to make light like it was before this alarm light is started?
Important thing is that this automation is not turned on between 22pm and 7am

@flega

You can’t as it doesn’t have this time restriction. So best to create a custom automation. Just turn on a toggle helper before you make the light flash red in your automation and use the toggle helper in the sensor light blueprint bypass option 3. Once you end the automation just make sure to turn the toggle helper OFF last.

Blacky :grinning:

@Blacky
I have made a new automation and it goes like this:

alias: CO2 red light
description: ""
triggers:
  - trigger: numeric_state
    entity_id:
      - sensor.co2_dnevna_dnevna_co2
    above: 1000
conditions: []
actions:
  - action: input_boolean.turn_on
    metadata: {}
    data: {}
    target:
      entity_id: input_boolean.test_switch_off
  - repeat:
      count: 2
      sequence:
        - action: light.turn_on
          metadata: {}
          data:
            rgb_color:
              - 255
              - 0
              - 0
            brightness_pct: 100
          target:
            entity_id: light.rgb_dnevna
        - delay:
            hours: 0
            minutes: 0
            seconds: 5
            milliseconds: 0
        - action: light.turn_on
          metadata: {}
          data:
            rgb_color:
              - 255
              - 0
              - 0
            brightness_pct: 13
          target:
            entity_id: light.rgb_dnevna
        - delay:
            hours: 0
            minutes: 0
            seconds: 5
            milliseconds: 0
  - action: input_boolean.turn_off
    metadata: {}
    data: {}
    target:
      entity_id: input_boolean.test_switch_off
mode: single

When I manualy run action it works ok, light turn to red with 100% and then 20% brightness and when it is done 2 times RGB light goes to previous state. But when trigger activate this automation, RGB light goes off and stays off. When I try to manualy turn on → off bypass off helper switch, RGB light goes on and instantly off. I have manged to turn light on, must activate bypass switch, than turn RGB light on, than deactivate bypass switch.

@flega

I havenet looked at your automation but you say it works… This part

The bypass in the sensor light blueprint should be option 3 - Enable the Bypass - Keep the Lights Current State You don’t want to turn it ON or OFF just pause the automation. I think your using option 2 and that will turn the light OFF.

Blacky :grinning: