From 5007b0acce598bf71121db5a43c15709e4ae1c92 Mon Sep 17 00:00:00 2001 From: longranger Date: Sun, 24 Apr 2022 08:00:50 -0700 Subject: [PATCH] Add abs press and dewpt. --- _data/weather-in-1.yaml | 36 +++++++++++++++++++++++++++++++----- _data/weather-out-n.yaml | 36 +++++++++++++++++++++++++++++++----- _data/weather-out-s.yaml | 36 +++++++++++++++++++++++++++++++----- 3 files changed, 93 insertions(+), 15 deletions(-) diff --git a/_data/weather-in-1.yaml b/_data/weather-in-1.yaml index f126117..4585022 100644 --- a/_data/weather-in-1.yaml +++ b/_data/weather-in-1.yaml @@ -1,3 +1,6 @@ +substitutions: + device_name: In1 + esphome: name: weather-in-1 @@ -38,11 +41,34 @@ i2c: sensor: - platform: bme280 temperature: - name: "TempIn1" - oversampling: 16x + name: Temp${device_name} + id: bme280_temperature pressure: - name: "PressIn1" + name: Press${device_name} + id: bme280_pressure humidity: - name: "HumidityIn1" + name: HumidityRel${device_name} + id: bme280_humidity address: 0x76 - update_interval: 60s + update_interval: 15s + # Templates from https://esphome.io/cookbook/bme280_environment.html + - platform: template + name: HumidityAbs${device_name} + lambda: |- + const float mw = 18.01534; // molar mass of water g/mol + const float r = 8.31447215; // Universal gas constant J/mol/K + return (6.112 * powf(2.718281828, (17.67 * id(bme280_temperature).state) / + (id(bme280_temperature).state + 243.5)) * id(bme280_humidity).state * mw) / + ((273.15 + id(bme280_temperature).state) * r); // in grams/m^3 + accuracy_decimals: 2 + update_interval: 15s + icon: 'mdi:water' + unit_of_measurement: 'g/m³' + - platform: template + name: DewPt${device_name} + lambda: |- + return (243.5*(log(id(bme280_humidity).state/100)+((17.67*id(bme280_temperature).state)/ + (243.5+id(bme280_temperature).state)))/(17.67-log(id(bme280_humidity).state/100)- + ((17.67*id(bme280_temperature).state)/(243.5+id(bme280_temperature).state)))); + unit_of_measurement: °C + icon: 'mdi:thermometer-alert' diff --git a/_data/weather-out-n.yaml b/_data/weather-out-n.yaml index 433ed2f..af90887 100644 --- a/_data/weather-out-n.yaml +++ b/_data/weather-out-n.yaml @@ -1,3 +1,6 @@ +substitutions: + device_name: OutN + esphome: name: weather-out-n @@ -38,11 +41,34 @@ i2c: sensor: - platform: bme280 temperature: - name: "TempOutN" - oversampling: 16x + name: Temp${device_name} + id: bme280_temperature pressure: - name: "PressOutN" + name: Press${device_name} + id: bme280_pressure humidity: - name: "HumidityOutN" + name: HumidityRel${device_name} + id: bme280_humidity address: 0x76 - update_interval: 60s + update_interval: 15s + # Templates from https://esphome.io/cookbook/bme280_environment.html + - platform: template + name: HumidityAbs${device_name} + lambda: |- + const float mw = 18.01534; // molar mass of water g/mol + const float r = 8.31447215; // Universal gas constant J/mol/K + return (6.112 * powf(2.718281828, (17.67 * id(bme280_temperature).state) / + (id(bme280_temperature).state + 243.5)) * id(bme280_humidity).state * mw) / + ((273.15 + id(bme280_temperature).state) * r); // in grams/m^3 + accuracy_decimals: 2 + update_interval: 15s + icon: 'mdi:water' + unit_of_measurement: 'g/m³' + - platform: template + name: DewPt${device_name} + lambda: |- + return (243.5*(log(id(bme280_humidity).state/100)+((17.67*id(bme280_temperature).state)/ + (243.5+id(bme280_temperature).state)))/(17.67-log(id(bme280_humidity).state/100)- + ((17.67*id(bme280_temperature).state)/(243.5+id(bme280_temperature).state)))); + unit_of_measurement: °C + icon: 'mdi:thermometer-alert' diff --git a/_data/weather-out-s.yaml b/_data/weather-out-s.yaml index 9695e8c..6396e88 100644 --- a/_data/weather-out-s.yaml +++ b/_data/weather-out-s.yaml @@ -1,3 +1,6 @@ +substitutions: + device_name: OutS + esphome: name: weather-out-s @@ -38,11 +41,34 @@ i2c: sensor: - platform: bme280 temperature: - name: "TempOutS" - oversampling: 16x + name: Temp${device_name} + id: bme280_temperature pressure: - name: "PressOutS" + name: Press${device_name} + id: bme280_pressure humidity: - name: "HumidityOutS" + name: HumidityRel${device_name} + id: bme280_humidity address: 0x76 - update_interval: 60s + update_interval: 15s + # Templates from https://esphome.io/cookbook/bme280_environment.html + - platform: template + name: HumidityAbs${device_name} + lambda: |- + const float mw = 18.01534; // molar mass of water g/mol + const float r = 8.31447215; // Universal gas constant J/mol/K + return (6.112 * powf(2.718281828, (17.67 * id(bme280_temperature).state) / + (id(bme280_temperature).state + 243.5)) * id(bme280_humidity).state * mw) / + ((273.15 + id(bme280_temperature).state) * r); // in grams/m^3 + accuracy_decimals: 2 + update_interval: 15s + icon: 'mdi:water' + unit_of_measurement: 'g/m³' + - platform: template + name: DewPt${device_name} + lambda: |- + return (243.5*(log(id(bme280_humidity).state/100)+((17.67*id(bme280_temperature).state)/ + (243.5+id(bme280_temperature).state)))/(17.67-log(id(bme280_humidity).state/100)- + ((17.67*id(bme280_temperature).state)/(243.5+id(bme280_temperature).state)))); + unit_of_measurement: °C + icon: 'mdi:thermometer-alert'