Code cleanup, in-line code comments. Added purple light to indicate required co2 sensor calibration.
This commit is contained in:
		@@ -3,19 +3,15 @@ esphome:
 | 
				
			|||||||
  platform: ESP32
 | 
					  platform: ESP32
 | 
				
			||||||
  board: nodemcu-32s
 | 
					  board: nodemcu-32s
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
#  # Dirty hack, because on_value_range does not trigger green if sensor
 | 
					# Startup animation
 | 
				
			||||||
#  # value is within green range on boot.
 | 
					 | 
				
			||||||
#on_boot:
 | 
					#on_boot:
 | 
				
			||||||
#  then:
 | 
					#  then:
 | 
				
			||||||
#      - output.set_level:
 | 
					
 | 
				
			||||||
#          id: led_green
 | 
					#script:
 | 
				
			||||||
#          level: 58%
 | 
					#  - id: startup_animation
 | 
				
			||||||
#      - output.set_level:
 | 
					#    then:
 | 
				
			||||||
#          id: led_red
 | 
					#      - delay: 5s
 | 
				
			||||||
#          level: 0%
 | 
					#      - 
 | 
				
			||||||
#      - text_sensor.template.publish:
 | 
					 | 
				
			||||||
#          id: co2_warn
 | 
					 | 
				
			||||||
#          state: "grün"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
wifi:
 | 
					wifi:
 | 
				
			||||||
  ssid: "Voltage-legacy"
 | 
					  ssid: "Voltage-legacy"
 | 
				
			||||||
@@ -62,7 +58,7 @@ output:
 | 
				
			|||||||
    pin: GPIO19
 | 
					    pin: GPIO19
 | 
				
			||||||
    id: led_blue
 | 
					    id: led_blue
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Example configuration entry
 | 
					# Define RGB mode for LED
 | 
				
			||||||
light:
 | 
					light:
 | 
				
			||||||
  - platform: rgb
 | 
					  - platform: rgb
 | 
				
			||||||
    id: co2_light
 | 
					    id: co2_light
 | 
				
			||||||
@@ -70,6 +66,7 @@ light:
 | 
				
			|||||||
    red: led_red
 | 
					    red: led_red
 | 
				
			||||||
    green: led_green
 | 
					    green: led_green
 | 
				
			||||||
    blue: led_blue
 | 
					    blue: led_blue
 | 
				
			||||||
 | 
					    internal: true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Initialize UART for Vindriktning sensor
 | 
					# Initialize UART for Vindriktning sensor
 | 
				
			||||||
uart:
 | 
					uart:
 | 
				
			||||||
@@ -90,11 +87,12 @@ sensor:
 | 
				
			|||||||
  - platform: wifi_signal
 | 
					  - platform: wifi_signal
 | 
				
			||||||
    name: "WiFi Signalstärke"
 | 
					    name: "WiFi Signalstärke"
 | 
				
			||||||
    update_interval: 60s
 | 
					    update_interval: 60s
 | 
				
			||||||
  # SCD30 CO2 +  Temperature + Humidity Sensor
 | 
					  # SCD30 CO2 +  temperature + humidity sensor
 | 
				
			||||||
  # • Luftqualität Kategorie 1: die LEDs leuchten grün (bis 800 ppm) 
 | 
					  # * air quality category 0: LED is purple, sensor needs calibration (<400ppm)
 | 
				
			||||||
  # • Luftqualität Kategorie 2: die LEDs leuchten gelb (900-1200 ppm) 
 | 
					  # • air quality category 1: LED is green (400-800ppm) 
 | 
				
			||||||
  # • Luftqualität Kategorie 3: die LEDs leuchten orange (1200 bis 1600ppm) 
 | 
					  # • air quality category 2: LED is yellow (900-1200ppm) 
 | 
				
			||||||
  # • Luftqualität Kategorie 4: die LEDs leuchten rot (ab 1600ppm) 
 | 
					  # • air quality category 3: LED is orange/amber (1200 bis 1600ppm) 
 | 
				
			||||||
 | 
					  # • air quality category 4: LED is red (1600-2000ppm) 
 | 
				
			||||||
  - platform: scd30
 | 
					  - platform: scd30
 | 
				
			||||||
    i2c_id: bus_a
 | 
					    i2c_id: bus_a
 | 
				
			||||||
    co2:
 | 
					    co2:
 | 
				
			||||||
@@ -102,29 +100,59 @@ sensor:
 | 
				
			|||||||
      id: co2_value
 | 
					      id: co2_value
 | 
				
			||||||
      accuracy_decimals: 1
 | 
					      accuracy_decimals: 1
 | 
				
			||||||
      on_value_range:
 | 
					      on_value_range:
 | 
				
			||||||
        - above: 380
 | 
					        - below: 400
 | 
				
			||||||
 | 
					          then:
 | 
				
			||||||
 | 
					            - text_sensor.template.publish:
 | 
				
			||||||
 | 
					                id: co2_warn
 | 
				
			||||||
 | 
					                state: "Kalibrierung nötig"
 | 
				
			||||||
 | 
					            - light.turn_on:
 | 
				
			||||||
 | 
					                id: co2_light
 | 
				
			||||||
 | 
					                red: 75%
 | 
				
			||||||
 | 
					                green: 0%
 | 
				
			||||||
 | 
					                blue: 100%
 | 
				
			||||||
 | 
					        - above: 400
 | 
				
			||||||
          below: 800
 | 
					          below: 800
 | 
				
			||||||
          then:
 | 
					          then:
 | 
				
			||||||
            - text_sensor.template.publish:
 | 
					            - text_sensor.template.publish:
 | 
				
			||||||
                id: co2_warn
 | 
					                id: co2_warn
 | 
				
			||||||
                state: "grün"
 | 
					                state: "grün"
 | 
				
			||||||
 | 
					            - light.turn_on:
 | 
				
			||||||
 | 
					                id: co2_light
 | 
				
			||||||
 | 
					                red: 0%
 | 
				
			||||||
 | 
					                green: 100%
 | 
				
			||||||
 | 
					                blue: 9%
 | 
				
			||||||
        - above: 800
 | 
					        - above: 800
 | 
				
			||||||
          below: 1200
 | 
					          below: 1200
 | 
				
			||||||
          then:
 | 
					          then:
 | 
				
			||||||
            - text_sensor.template.publish:
 | 
					            - text_sensor.template.publish:
 | 
				
			||||||
                id: co2_warn
 | 
					                id: co2_warn
 | 
				
			||||||
                state: "gelb"
 | 
					                state: "gelb"
 | 
				
			||||||
 | 
					            - light.turn_on:
 | 
				
			||||||
 | 
					                id: co2_light
 | 
				
			||||||
 | 
					                red: 100%
 | 
				
			||||||
 | 
					                green: 100%
 | 
				
			||||||
 | 
					                blue: 0%
 | 
				
			||||||
        - above: 1200
 | 
					        - above: 1200
 | 
				
			||||||
          below: 1600
 | 
					          below: 1600
 | 
				
			||||||
          then:
 | 
					          then:
 | 
				
			||||||
            - text_sensor.template.publish:
 | 
					            - text_sensor.template.publish:
 | 
				
			||||||
                id: co2_warn
 | 
					                id: co2_warn
 | 
				
			||||||
                state: "orange"
 | 
					                state: "orange"
 | 
				
			||||||
 | 
					            - light.turn_on:
 | 
				
			||||||
 | 
					                id: co2_light
 | 
				
			||||||
 | 
					                red: 100%
 | 
				
			||||||
 | 
					                green: 75%
 | 
				
			||||||
 | 
					                blue: 0%
 | 
				
			||||||
        - above: 1600
 | 
					        - above: 1600
 | 
				
			||||||
          then:
 | 
					          then:
 | 
				
			||||||
            - text_sensor.template.publish:
 | 
					            - text_sensor.template.publish:
 | 
				
			||||||
                id: co2_warn
 | 
					                id: co2_warn
 | 
				
			||||||
                state: "rot"
 | 
					                state: "rot"
 | 
				
			||||||
 | 
					            - light.turn_on:
 | 
				
			||||||
 | 
					                id: co2_light
 | 
				
			||||||
 | 
					                red: 100%
 | 
				
			||||||
 | 
					                green: 0%
 | 
				
			||||||
 | 
					                blue: 0%
 | 
				
			||||||
    temperature:
 | 
					    temperature:
 | 
				
			||||||
      name: "Schlafzimmer Temperatur"
 | 
					      name: "Schlafzimmer Temperatur"
 | 
				
			||||||
      accuracy_decimals: 2
 | 
					      accuracy_decimals: 2
 | 
				
			||||||
@@ -214,8 +242,3 @@ switch:
 | 
				
			|||||||
      - remote_transmitter.transmit_samsung:
 | 
					      - remote_transmitter.transmit_samsung:
 | 
				
			||||||
          data: 0xE0E040BF
 | 
					          data: 0xE0E040BF
 | 
				
			||||||
          nbits: 32
 | 
					          nbits: 32
 | 
				
			||||||
#script:
 | 
					 | 
				
			||||||
#  - id: startup_animation
 | 
					 | 
				
			||||||
#    then:
 | 
					 | 
				
			||||||
#      - delay: 5s
 | 
					 | 
				
			||||||
#      - 
 | 
					 | 
				
			||||||
		Reference in New Issue
	
	Block a user