Bonjour,
Plutôt qu’ouvrir un nouveau post je continue ici.
Voici mon code:
substitutions:
device_name: co2-temp
time_timezone: "Europe/Paris"
friendly_name: co2
esphome:
name: ${device_name}
esp8266:
board: esp01_1m
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "dC5e8iZGcjBOnqNESrzmBDPVbYde3g36op3sUlGfrXc="
ota:
- platform: esphome
password: "01f0d019d6f0eacc1a6e88ddaa595092"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
manual_ip:
static_ip: 192.168.1.234
gateway: 192.168.1.1
subnet: 255.255.255.0
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Co2 Fallback Hotspot"
password: "URtgpx24B9jE"
captive_portal:
uart:
tx_pin: GPIO12
rx_pin: GPIO13
baud_rate: 9600
time:
- platform: homeassistant
id: ha_time
binary_sensor:
- platform: status
name: "${friendly_name} Status"
switch:
- platform: restart
name: "${friendly_name} Restart"
sensor:
- platform: mhz19
co2:
name: "${friendly_name} valeur"
id: co2_valeur
filters:
- sliding_window_moving_average:
window_size: 30
send_every: 30
automatic_baseline_calibration: false
temperature:
name: "${friendly_name} temp"
id: co2_temp
update_interval: 60s
- platform: wifi_signal
name: "${friendly_name} WiFi Signal"
update_interval: 60s
- platform: template
name: "{$friendly_name} average"
id: co2_average
unit_of_measurement: ppm
lambda: |-
return id(co2_valeur).state;
update_interval: 60s
filters:
- sliding_window_moving_average:
window_size: 120
send_every: 1
on_value:
then:
- script.execute: update_co2
text_sensor:
- platform: template
name: "CO2 index"
id: co2_index
script:
- id: update_co2
mode: restart
then:
- if:
condition:
or:
- sensor.in_range:
id: co2_average
above: 1200
then:
- text_sensor.template.publish:
id: co2_index
state: Mauvais
- script.execute: show_tr_bad
else:
- if:
condition:
or:
- sensor.in_range:
id: co2_average
above: 800
then:
- text_sensor.template.publish:
id: co2_index
state: Mediocre
- script.execute: show_bad
else:
- if:
condition:
or:
- sensor.in_range:
id: co2_average
above: 400
then:
- text_sensor.template.publish:
id: co2_index
state: Acceptable
- script.execute: show_acceptable
else:
- text_sensor.template.publish:
id: co2_index
state: Bon
- script.execute: show_good
# Configuration for showing AQI status with the RGB LED
- id: show_tr_bad
then:
- if:
condition:
- lambda: 'return id(ha_time).now().hour < 23 && id(ha_time).now().hour > 7 ;'
then:
- light.turn_on:
id: rgb_led
brightness: 30%
red: 80%
green: 0%
blue: 20%
else:
- light.turn_off:
id: rgb_led
- id: show_bad
then:
- if:
condition:
- lambda: 'return id(ha_time).now().hour < 23 && id(ha_time).now().hour > 7 ;'
then:
- light.turn_on:
id: rgb_led
brightness: 30%
red: 100%
green: 60%
blue: 20%
else:
- light.turn_off:
id: rgb_led
- id: show_acceptable
then:
- if:
condition:
- lambda: 'return id(ha_time).now().hour < 23 && id(ha_time).now().hour > 7 ;'
then:
- light.turn_on:
id: rgb_led
brightness: 30%
red: 100%
green: 87%
blue: 20%
else:
- light.turn_off:
id: rgb_led
- id: show_good
then:
- if:
condition:
- lambda: 'return id(ha_time).now().hour < 23 && id(ha_time).now().hour > 7 ;'
then:
- light.turn_on:
id: rgb_led
brightness: 30%
red: 0%
green: 60%
blue: 40%
else:
- light.turn_off:
id: rgb_led
light:
- platform: neopixelbus
type: GRB
variant: WS2812x
pin: GPIO4
num_leds: 4
name: "${friendly_name} leds"
id: rgb_led
mon souci est que les leds passent au bleu ou vert pendant 3,4 secondes tous les minutes.
J’ai un montage similaire avec un PMS5003 et il fonctionne correctement ici
Des idées?