[Concours] PMS5003 dans boitier Vindrikting

Bonsoir,

Le capteur Ikea HS à l’été dernier (surchauffe) et ayant un PMS5003 avec un ESP-12F D1 mini.
Pour quoi ne pas se servir du boitier et d’ajouter 4 leds au projet.

La photo:

Le code sous ESPHome sur une idée de Sharing my experiences - Hardware extensions - AirGradient Forum

esphome:
  name: qualite-air-led
  friendly_name: qualite-air-led

esp8266:
  board: esp01_1m

# Enable logging
logger:
  baud_rate: 0   
  level: DEBUG 
  esp8266_store_log_strings_in_flash: False

# Enable Home Assistant API
api:
  encryption:
    key: "vFVXdRET6br/DfD3rGYiZwJpm7xOfFJkxsWVvqiCgDY="

ota:
  platform: esphome
  password: "bf23326420ea137ca0fb267ab868efe9"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  manual_ip:
    static_ip: 192.168.1.240
    gateway: 192.168.1.1
    subnet: 255.255.255.0

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Qualite-Air-Led Fallback Hotspot"
    password: "jtqyMJk14s3Z"

captive_portal:

uart:
  rx_pin: GPIO2 #D4
  baud_rate: 9600

time:
  - platform: homeassistant
    id: ha_time

sensor:
  - platform: pmsx003
    type: PMSX003
    pm_1_0:
      name: "particule_1-0"
      id: pm1
      filters:
        - sliding_window_moving_average:
            window_size: 30
            send_every: 30
    pm_2_5:
      name: "particule_2-5"
      id: pm_2_5
      filters:
        - sliding_window_moving_average:
            window_size: 30
            send_every: 30
    pm_10_0:
      name: "particule_10-0"
      id: pm_10
      filters:
        - sliding_window_moving_average:
            window_size: 30
            send_every: 30
  - platform: template
    name: "particule_2-5 average"
    id: pm_2_5_avg_24h
    icon: mdi:chemical-weapon
    unit_of_measurement: µg/m³
    lambda: |-
      return id(pm_2_5).state;
    update_interval: 60s
    filters:
      - sliding_window_moving_average:
          window_size: 120
          send_every: 1
    on_value:
      then:
        - script.execute: update_aqi

  - platform: template
    name: "particule_10-0 average"
    id: pm_10_avg_24h
    icon: mdi:chemical-weapon
    unit_of_measurement: µg/m³
    lambda: |-
      return id(pm_10).state;
    update_interval: 60s
    filters:
      - sliding_window_moving_average:
          window_size: 120
          send_every: 1
    on_value:
      then:
        - script.execute: update_aqi

text_sensor:
  - platform: template
    name: "Airgradient Air Quality Index"
    id: aqi
    icon: mdi:air-filter
    
script:
  - id: update_aqi
    mode: restart
    then:
      - if:
          condition:
            or:
              - sensor.in_range:
                  id: pm_2_5_avg_24h
                  above: 25
              - sensor.in_range:
                  id: pm_10_avg_24h
                  above: 50
          then:
            - text_sensor.template.publish:
                id: aqi
                state: Tres Mauvais
            - script.execute: show_tr_bad
          else:
            - if:
                condition:
                  or:
                    - sensor.in_range:
                        id: pm_2_5_avg_24h
                        above: 20
                    - sensor.in_range:
                        id: pm_10_avg_24h
                        above: 40
                then:
                  - text_sensor.template.publish:
                      id: aqi
                      state: Mauvais
                  - script.execute: show_bad
                else:
                  - if:
                      condition:
                        or:
                          - sensor.in_range:
                              id: pm_2_5_avg_24h
                              above: 10
                          - sensor.in_range:
                              id: pm_10_avg_24h
                              above: 20
                      then:
                        - text_sensor.template.publish:
                            id: aqi
                            state: Mediocre
                        - script.execute: show_acceptable
                      else:
                        - text_sensor.template.publish:
                            id: aqi
                            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 < 22 && id(ha_time).now().hour > 9 ;'
          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 < 22 && id(ha_time).now().hour > 9 ;'
          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 < 22 && id(ha_time).now().hour > 9 ;'
          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 < 22 && id(ha_time).now().hour > 9 ;'
          then:            
            - light.turn_on:
                id: rgb_led
                brightness: 30%
                red: 0%
                green: 60%
                blue: 40%
          else:
            - light.turn_off:
                id: rgb_led
          
interval:
  - interval: 120s
    then:
      - switch.turn_on: pms_set
      - delay: 20s
      - switch.turn_off: pms_set                
switch:
  - platform: gpio
    pin: 
      number: GPIO0 #D3
    id: pms_set
    name: "Debut mesure"

  - platform: restart
    name: "pms_restart"

light:
  - platform: neopixelbus
    type: GRB
    variant: WS2812x
    pin: GPIO4
    num_leds: 4
    name: "4 leds"
    id: rgb_led
1 « J'aime »