Skip to content

Instantly share code, notes, and snippets.

@schoenwaldnils
Created January 30, 2024 19:18
Show Gist options
  • Save schoenwaldnils/7a17b4b4bfdef8c6f7456e4457885722 to your computer and use it in GitHub Desktop.
Save schoenwaldnils/7a17b4b4bfdef8c6f7456e4457885722 to your computer and use it in GitHub Desktop.
CO2 light home assistant automations
- id: #censored#
alias: Air bad!
description: ''
trigger:
- type: carbon_dioxide
platform: device
device_id: #censored#
entity_id: sensor.qingping_air_monitor_lite_co2_carbon_dioxide
domain: sensor
above: 2000
condition:
- type: is_not_open
condition: device
device_id: #censored#
entity_id: binary_sensor.fenster_nils_contact
domain: binary_sensor
action:
- service: notify.mobile_app
data:
message: 'Luft schlecht! '
- service: notify.mobile_app_s22_susi
data:
title: Luft
message: schlecht!
mode: single
- id: #censored#
alias: Air clean again
description: ''
trigger:
- type: carbon_dioxide
platform: device
device_id: #censored#
entity_id: sensor.qingping_air_monitor_lite_co2_carbon_dioxide
domain: sensor
below: 600
for:
hours: 0
minutes: 0
seconds: 10
condition:
- condition: template
value_template: '{{ now() - state_attr(''automation.bad_air'', ''last_triggered'')
< timedelta(hours=2) }}'
action:
- service: notify.mobile_app
data:
message: Luft wieder gut :)
mode: single
- id: #censored#
alias: CO2-Ampel
description: ''
trigger:
- platform: time_pattern
minutes: /1
- platform: state
entity_id:
- light.co2_lights
to: 'on'
condition:
- condition: state
entity_id: light.co2_lights
state: 'on'
action:
- service: light.turn_on
data:
color_name: '{{ states(''input_text.co2_color'') }}'
target:
entity_id: light.co2_lights
mode: single
- id: #censored#
alias: Co2 color
description: ''
trigger:
- platform: time_pattern
minutes: /1
condition: []
action:
- parallel:
- alias: '> 3000'
if:
- condition: numeric_state
entity_id: sensor.qingping_air_monitor_lite_co2_carbon_dioxide
above: 3000
then:
- service: input_text.set_value
data:
value: purple
target:
entity_id: input_text.co2_color
- alias: 2000 - 3000
if:
- condition: numeric_state
entity_id: sensor.qingping_air_monitor_lite_co2_carbon_dioxide
below: 3000
above: 2000
then:
- service: input_text.set_value
data:
value: red
target:
entity_id: input_text.co2_color
- alias: 1500 - 2000
if:
- condition: numeric_state
entity_id: sensor.qingping_air_monitor_lite_co2_carbon_dioxide
below: 2000
above: 1500
then:
- service: input_text.set_value
data:
value: orange
target:
entity_id: input_text.co2_color
- alias: 1000 - 1500
if:
- condition: numeric_state
entity_id: sensor.qingping_air_monitor_lite_co2_carbon_dioxide
below: 1500
above: 1000
then:
- service: input_text.set_value
data:
value: yellow
target:
entity_id: input_text.co2_color
- alias: 500 - 1000
if:
- condition: numeric_state
entity_id: sensor.qingping_air_monitor_lite_co2_carbon_dioxide
below: 1000
above: 500
then:
- service: input_text.set_value
data:
value: green
target:
entity_id: input_text.co2_color
- alias: < 500
if:
- condition: numeric_state
entity_id: sensor.qingping_air_monitor_lite_co2_carbon_dioxide
below: 500
then:
- service: input_text.set_value
data:
value: blue
target:
entity_id: input_text.co2_color
mode: single
- id: #censored#
alias: 'Time: CO2 lights'
description: 'turn on CO2 lights in the morning '
trigger:
- platform: time
at: 08:00:00
condition:
- condition: state
entity_id: input_boolean.someone_home
state: 'on'
- condition: state
entity_id: light.co2_lights
state: 'off'
action:
- service: light.turn_on
data:
brightness_pct: 100
transition: 300
target:
entity_id: light.co2_lights
mode: single
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment