mirror of
https://codeberg.org/icewind/taspromto.git
synced 2026-06-03 16:44:11 +02:00
allow passing trough mh-z19 co2 readings
This commit is contained in:
parent
f7938d1d95
commit
5aa9718e30
1 changed files with 15 additions and 0 deletions
|
|
@ -23,6 +23,7 @@ pub struct DeviceState {
|
||||||
pub power_watts: Option<f32>,
|
pub power_watts: Option<f32>,
|
||||||
pub power_yesterday: Option<f32>,
|
pub power_yesterday: Option<f32>,
|
||||||
pub power_today: Option<f32>,
|
pub power_today: Option<f32>,
|
||||||
|
pub co2: Option<f32>,
|
||||||
pub mi_temp_devices: BTreeMap<BDAddr, MiTempState>,
|
pub mi_temp_devices: BTreeMap<BDAddr, MiTempState>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -52,6 +53,12 @@ impl DeviceState {
|
||||||
{
|
{
|
||||||
self.power_today = Some(today);
|
self.power_today = Some(today);
|
||||||
}
|
}
|
||||||
|
if let Some(today) = json["MHZ19B"]["CarbonDioxide"]
|
||||||
|
.as_number()
|
||||||
|
.and_then(|num| f32::try_from(num).ok())
|
||||||
|
{
|
||||||
|
self.co2 = Some(today);
|
||||||
|
}
|
||||||
|
|
||||||
for (key, value) in json.entries() {
|
for (key, value) in json.entries() {
|
||||||
if let Some(addr) = key.strip_prefix("MJ_HT_V1-") {
|
if let Some(addr) = key.strip_prefix("MJ_HT_V1-") {
|
||||||
|
|
@ -144,6 +151,14 @@ pub fn format_device_state<W: Write>(
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Some(co2) = state.co2 {
|
||||||
|
writeln!(
|
||||||
|
writer,
|
||||||
|
"sensor_co2{{tasmota_id=\"{}\", name=\"{}\"}} {}",
|
||||||
|
device.hostname, state.name, co2
|
||||||
|
)?;
|
||||||
|
}
|
||||||
|
|
||||||
for (addr, state) in state.mi_temp_devices.iter() {
|
for (addr, state) in state.mi_temp_devices.iter() {
|
||||||
format_mi_temp_state(&mut writer, *addr, mi_temp_names, state)?;
|
format_mi_temp_state(&mut writer, *addr, mi_temp_names, state)?;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue