mirror of
https://codeberg.org/icewind/taspromto.git
synced 2026-08-02 12:14:45 +02:00
support rtl433 temp sensors
This commit is contained in:
parent
217298c1c7
commit
347cfe2054
6 changed files with 137 additions and 24 deletions
11
src/topic.rs
11
src/topic.rs
|
|
@ -15,6 +15,7 @@ pub enum Topic {
|
|||
Energy1(Device),
|
||||
Energy2(Device),
|
||||
DsmrPower(Device),
|
||||
Rtl(Device, String),
|
||||
}
|
||||
|
||||
impl Topic {
|
||||
|
|
@ -44,6 +45,7 @@ impl Topic {
|
|||
Topic::Energy1(device) => device,
|
||||
Topic::Energy2(device) => device,
|
||||
Topic::DsmrPower(device) => device,
|
||||
Topic::Rtl(device, _) => device,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -56,6 +58,15 @@ impl From<&str> for Topic {
|
|||
};
|
||||
return Topic::Msg(device);
|
||||
}
|
||||
if let Some((device, topic)) = raw
|
||||
.strip_prefix("rtl_433/")
|
||||
.and_then(|topic| topic.split_once('/'))
|
||||
{
|
||||
let device = Device {
|
||||
hostname: device.to_string(),
|
||||
};
|
||||
return Topic::Rtl(device, topic.into());
|
||||
}
|
||||
if let Some(name) = raw.strip_suffix("/water") {
|
||||
let device = Device {
|
||||
hostname: name.to_string(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue