Homelab, Linux, JS & ABAP (~˘▾˘)~
 

[Home Assistant] Mushroom Template card – Badge Icon

Somehow, I’ve only just realized that a badge icon can be used to display another entity status on a template card, even though it’s written in the documentation. I now use it to display the status of presence or motion sensors in the respective rooms.

badge_icon: >-
  {{ "mdi:motion-sensor" if states("binary_sensor.0xb4e3f9fffeb689d4_occupancy")  == "on" }}
badge_color: >- 
  {{ "green" if states("binary_sensor.0xb4e3f9fffeb689d4_occupancy") == "on" }}

[Home Assistant] Motion sensor in combination with Adaptive Lightning

I have some lights in my garden which are turned on in the night and are controlled by the Adaptive Lighting component, to automatically adjust brightness and color during the night. But if someone comes home late and this is detected by a motion sensor, I wanted to increase the brightness of all the lights in the garden for a short time.

Increasing the brightness was easy, as it can be done by using the light.turn_on service. However, it took me a few minutes to figure out how to reactivate adaptive lighting on these lights when motion is no longer detected. But it’s actually super simple (and it’s directly written on the GitHub start page here and here). You just have to deactivate the “manually controlled” flag that got activated by “manually” increasing the brightness. Following an example with a single motion sensor (binary_sensor.haustuer_motion), a lamp (light.haustur_light) and the adaptive lightning switch entity (switch.adaptive_lighting_haustuer).

alias: Motion sensor front door
description: "Increase brightness for three minutes when motion is detected"
trigger:
  - platform: state
    entity_id:
      - binary_sensor.haustuer_motion
    to: "on"
condition:
  - condition: state
    entity_id: sun.sun
    state: below_horizon
action:
  - service: light.turn_on
    data:
      transition: 3
      brightness_pct: 70
    target:
      entity_id: light.haustur_light
  - wait_for_trigger:
      - platform: state
        entity_id:
          - binary_sensor.haustuer_motion
        to: "off"
        for:
          hours: 0
          minutes: 3
          seconds: 0
    timeout:
      hours: 0
      minutes: 0
      seconds: 0
      milliseconds: 0
  - service: adaptive_lighting.set_manual_control
    data:
      manual_control: false
      entity_id: switch.adaptive_lighting_haustuer
      lights:
        - light.haustur_light
mode: single

[Home Assistant] Control lights with multiple motion sensors

Create group of motion sensors in groups.yaml
https://www.home-assistant.io/integrations/group/

cellar_motion:
  name: Cellar Presence
  icon: mdi:motion-sensor
  entities:
    - binary_sensor.bewegungsmelder_xxx_ias_zone
    - binary_sensor.bewegungsmelder_xxx_ias_zone

Next, if you have more than one light you’d like to control, create a group of lights in your configuration.yaml
https://www.home-assistant.io/integrations/light.group/

# Light Groups      
light:
  - platform: group
    name: Cellar Lights
    entities:
      - light.ikea_of_sweden_tradfri_bulb_e27_ww_806lm_xxx_level_on_off
      - light.ikea_of_sweden_tradfri_bulb_e27_ww_806lm_xxx_level_on_off   

And finally use both in an automation

alias: My motion activated lights
description: Turn on a light when motion is detected.
trigger:
  - platform: state
    entity_id: group.cellar_motion
    from: 'off'
    to: 'on'
condition: []
action:
  - service: light.turn_on
    target:
      entity_id: light.cellar_lights
    data: {}
  - wait_for_trigger:
      platform: state
      entity_id: group.cellar_motion
      from: 'on'
      to: 'off'
  - delay: 120
  - service: light.turn_off
    target:
      entity_id: light.cellar_lights
    data: {}
mode: restart
max_exceeded: silent # https://www.home-assistant.io/docs/automation/modes/