Created
May 11, 2023 18:59
-
-
Save grischard/aa87e7447853e9140866cc2ef74ff5a6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
substitutions: | |
# device/name is significant for Lunar.app | |
# Sensors: TSL2561 (light), BME280 (hum/temp), sgp30 (tvoc) | |
device: lunarsensor | |
name: Lunar Sensor | |
reboot_timeout: 1h | |
update_interval: 60s | |
i2c_sda: GPIO33 | |
i2c_scl: GPIO32 | |
board: nodemcu-32s # https://docs.ai-thinker.com/_media/esp32/docs/nodemcu-32s_product_specification.pdf | |
esphome: | |
name: ${device} | |
status_led: | |
pin: | |
number: GPIO2 # blue LED on nodemcu-32s board. Red LED isn't connected to GPIO and can't be turned off. | |
<<: !include common/esp32.yaml | |
<<: !include common/common.yaml | |
<<: !include common/i2c.yaml | |
sensor: | |
- !include common/sensor/wifi-signal.yaml | |
- !include common/sensor/uptime.yaml | |
- platform: bme280 | |
temperature: | |
name: "${name} Temperature" | |
id: ${device}_temperature | |
pressure: | |
name: "${name} Pressure" | |
id: ${device}_pressure | |
humidity: | |
name: "${name} Relative Humidity" | |
id: ${device}_humidity | |
address: 0x76 | |
update_interval: 15s | |
- platform: sgp30 | |
eco2: | |
name: "${name} eCO2" | |
accuracy_decimals: 1 | |
tvoc: | |
name: "${name} TVOC" | |
accuracy_decimals: 1 | |
compensation: | |
temperature_source: ${device}_temperature | |
humidity_source: ${device}_humidity | |
store_baseline: yes | |
address: 0x58 | |
- platform: absolute_humidity | |
name: ${name} Absolute Humidity | |
temperature: ${device}_temperature | |
humidity: ${device}_humidity | |
accuracy_decimals: 2 | |
- platform: template | |
name: "${name} Dew Point" | |
lambda: return (243.5*(log(id(${device}_humidity).state/100)+((17.67*id(${device}_temperature).state)/ | |
(243.5+id(${device}_temperature).state)))/(17.67-log(id(${device}_humidity).state/100)- | |
((17.67*id(${device}_temperature).state)/(243.5+id(${device}_temperature).state)))); | |
unit_of_measurement: °C | |
icon: 'mdi:thermometer-alert' | |
- platform: tsl2561 | |
name: "Ambient Light TSL2561" | |
id: ambient_light_tsl2561 | |
update_interval: 1s | |
gain: 1x | |
filters: | |
- filter_out: 65535 | |
- filter_out: nan | |
- sliding_window_moving_average: | |
window_size: 15 | |
send_every: 2 | |
send_first_at: 2 | |
on_raw_value: | |
then: | |
- lambda: |- | |
if (isnan(x)) { | |
id(ambient_light_tsl2561).set_gain(esphome::tsl2561::TSL2561_GAIN_1X); | |
id(ambient_light_tsl2561).set_integration_time(esphome::tsl2561::TSL2561_INTEGRATION_14MS); | |
} else if (x < 30) { | |
id(ambient_light_tsl2561).set_gain(esphome::tsl2561::TSL2561_GAIN_16X); | |
id(ambient_light_tsl2561).set_integration_time(esphome::tsl2561::TSL2561_INTEGRATION_402MS); | |
} else if (x > 30000) { | |
id(ambient_light_tsl2561).set_gain(esphome::tsl2561::TSL2561_GAIN_1X); | |
id(ambient_light_tsl2561).set_integration_time(esphome::tsl2561::TSL2561_INTEGRATION_14MS); | |
} else if (x > 400) { | |
id(ambient_light_tsl2561).set_gain(esphome::tsl2561::TSL2561_GAIN_1X); | |
id(ambient_light_tsl2561).set_integration_time(esphome::tsl2561::TSL2561_INTEGRATION_101MS); | |
} else { | |
id(ambient_light_tsl2561).set_gain(esphome::tsl2561::TSL2561_GAIN_1X); | |
id(ambient_light_tsl2561).set_integration_time(esphome::tsl2561::TSL2561_INTEGRATION_402MS); | |
} | |
button: | |
- platform: restart | |
name: "${name} Restart" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment