mirror of
https://github.com/athom-tech/esp32-configs.git
synced 2026-07-27 19:56:13 +00:00
Fix missing updates of AQI for CO2 sensor
The switch status_light is supposed to toggle whether the LED reflects the current air quality, but turning it off also disabled updates to the AQI text sensor, leading to outdated values in HomeAssistant. Now the text sensor is always updated and the switch only controls the LED.
This commit is contained in:
+37
-20
@@ -143,11 +143,13 @@ sensor:
|
||||
name: "CO2"
|
||||
id: "co2"
|
||||
on_value:
|
||||
if:
|
||||
condition:
|
||||
switch.is_on: status_light
|
||||
then:
|
||||
- script.execute: update_aqi
|
||||
- script.execute:
|
||||
id: update_aqi
|
||||
- if:
|
||||
condition:
|
||||
switch.is_on: status_light
|
||||
then:
|
||||
- script.execute: update_light
|
||||
temperature:
|
||||
name: "Temperature"
|
||||
id: "temperature"
|
||||
@@ -326,14 +328,37 @@ script:
|
||||
then:
|
||||
- if:
|
||||
condition:
|
||||
or:
|
||||
- sensor.in_range:
|
||||
id: co2
|
||||
above: 1500
|
||||
sensor.in_range:
|
||||
id: co2
|
||||
above: 1500
|
||||
then:
|
||||
- text_sensor.template.publish:
|
||||
id: aqi
|
||||
state: Bad
|
||||
else:
|
||||
- if:
|
||||
condition:
|
||||
sensor.in_range:
|
||||
id: co2
|
||||
above: 800
|
||||
below: 1500
|
||||
then:
|
||||
- text_sensor.template.publish:
|
||||
id: aqi
|
||||
state: Acceptable
|
||||
else:
|
||||
- text_sensor.template.publish:
|
||||
id: aqi
|
||||
state: Good
|
||||
- id: update_light
|
||||
mode: restart
|
||||
then:
|
||||
- if:
|
||||
condition:
|
||||
text_sensor.state:
|
||||
id: aqi
|
||||
state: Bad
|
||||
then:
|
||||
- light.turn_on:
|
||||
id: led
|
||||
brightness: 100%
|
||||
@@ -343,15 +368,10 @@ script:
|
||||
else:
|
||||
- if:
|
||||
condition:
|
||||
or:
|
||||
- sensor.in_range:
|
||||
id: co2
|
||||
above: 800
|
||||
below: 1500
|
||||
text_sensor.state:
|
||||
id: aqi
|
||||
state: Acceptable
|
||||
then:
|
||||
- text_sensor.template.publish:
|
||||
id: aqi
|
||||
state: Acceptable
|
||||
- light.turn_on:
|
||||
id: led
|
||||
brightness: 50%
|
||||
@@ -359,9 +379,6 @@ script:
|
||||
green: 100%
|
||||
blue: 0%
|
||||
else:
|
||||
- text_sensor.template.publish:
|
||||
id: aqi
|
||||
state: Good
|
||||
- light.turn_on:
|
||||
id: led
|
||||
brightness: 50%
|
||||
|
||||
Reference in New Issue
Block a user