The automation to show the CO2 warning light (e.g. red if CO2 > 1000 ppm) is done in Home Assistant, but could also be implemented using ESPHome :ref:`Automations <automation>`.
..code-block:: yaml
# Turn on a light with the related color
automation:
- id: '1601241280015'
alias: Light CO2 On
description: ''
trigger:
- platform: numeric_state
entity_id: sensor.mh_z19_co2_value
above: 1000
condition: []
action:
- service: light.turn_on
data:
color_name: red
entity_id: light.pl2
mode: single
- id: '1601241280016'
alias: Light CO2 Off
description: ''
trigger:
- platform: numeric_state
entity_id: sensor.mh_z19_co2_value
below: 800
condition: []
action:
- service: light.turn_off
entity_id: light.pl2
mode: single
- alias: "State Light Mapping"
trigger:
platform: time_pattern
# You can also match on interval. This will match every 5 minutes
minutes: "/5"
action:
- service: light.turn_on
data_template:
entity_id: light.pl1
brightness_pct: 30
color_name: >
{% set map = {'on': 'green', 'off': 'red'} %}
{% set state = states('binary_sensor.bad_status') %}