|
|
@ -37,6 +37,10 @@ where |
|
|
|
format!("{}/sections/{}", self.prefix.as_ref(), section_id) |
|
|
|
format!("{}/sections/{}", self.prefix.as_ref(), section_id) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn section_state(&self, section_id: SectionId) -> String { |
|
|
|
|
|
|
|
format!("{}/sections/{}/state", self.prefix.as_ref(), section_id) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fn programs(&self) -> String { |
|
|
|
fn programs(&self) -> String { |
|
|
|
format!("{}/programs", self.prefix.as_ref()) |
|
|
|
format!("{}/programs", self.prefix.as_ref()) |
|
|
|
} |
|
|
|
} |
|
|
@ -160,6 +164,19 @@ impl MqttInterface { |
|
|
|
Ok(()) |
|
|
|
Ok(()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub async fn publish_section_state(&mut self, section_id: SectionId, state: bool) -> eyre::Result<()> { |
|
|
|
|
|
|
|
let payload: Vec<u8> = state.to_string().into(); |
|
|
|
|
|
|
|
self.client |
|
|
|
|
|
|
|
.publish( |
|
|
|
|
|
|
|
self.topics.section_state(section_id), |
|
|
|
|
|
|
|
QoS::AtLeastOnce, |
|
|
|
|
|
|
|
true, |
|
|
|
|
|
|
|
payload, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
.await?; |
|
|
|
|
|
|
|
Ok(()) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pub async fn publish_programs(&mut self, programs: &Programs) -> eyre::Result<()> { |
|
|
|
pub async fn publish_programs(&mut self, programs: &Programs) -> eyre::Result<()> { |
|
|
|
let program_ids: Vec<_> = programs.keys().cloned().collect(); |
|
|
|
let program_ids: Vec<_> = programs.keys().cloned().collect(); |
|
|
|
let program_ids_payload = serde_json::to_vec(&program_ids)?; |
|
|
|
let program_ids_payload = serde_json::to_vec(&program_ids)?; |
|
|
|