diff --git a/fan-controller/build.rs b/fan-controller/build.rs index 0fbbd8e..2db104e 100644 --- a/fan-controller/build.rs +++ b/fan-controller/build.rs @@ -272,8 +272,8 @@ fn set_discovery_payload(git_hash: &str) { Component::Fan { name: Some("Fan 1"), unique_id: Some(topic::fan_controller::fan_1::UNIQUE_ID), - state_topic: Some(topic::fan_controller::fan_1::STATE), - command_topic: topic::fan_controller::fan_1::COMMAND, + state_topic: Some(topic::fan_controller::fan_1::on::STATE), + command_topic: topic::fan_controller::fan_1::on::COMMAND, percentage_state_topic: Some(topic::fan_controller::fan_1::percentage::STATE), percentage_command_topic: Some( topic::fan_controller::fan_1::percentage::COMMAND, @@ -287,8 +287,8 @@ fn set_discovery_payload(git_hash: &str) { Component::Fan { name: Some("Fan 2"), unique_id: Some(topic::fan_controller::fan_2::UNIQUE_ID), - state_topic: Some(topic::fan_controller::fan_2::STATE), - command_topic: topic::fan_controller::fan_2::COMMAND, + state_topic: Some(topic::fan_controller::fan_2::on::STATE), + command_topic: topic::fan_controller::fan_2::on::COMMAND, percentage_state_topic: Some(topic::fan_controller::fan_2::percentage::STATE), percentage_command_topic: Some( topic::fan_controller::fan_2::percentage::COMMAND, diff --git a/fan-controller/src/main.rs b/fan-controller/src/main.rs index 5d77457..153e0f0 100644 --- a/fan-controller/src/main.rs +++ b/fan-controller/src/main.rs @@ -555,11 +555,11 @@ impl Publish for OutgoingPublish { OutgoingPublish::UpdateState { fan: Fan::One, payload: _, - } => topic::fan_controller::fan_1::STATE, + } => topic::fan_controller::fan_1::percentage::STATE, OutgoingPublish::UpdateState { fan: Fan::Two, payload: _, - } => topic::fan_controller::fan_2::STATE, + } => topic::fan_controller::fan_2::percentage::STATE, } } diff --git a/fan-controller/src/task.rs b/fan-controller/src/task.rs index 1bc2bec..30c3ebf 100644 --- a/fan-controller/src/task.rs +++ b/fan-controller/src/task.rs @@ -631,19 +631,19 @@ const SUBSCRIPTIONS: [Subscription; SUBSCRIPTIONS_LENGTH] = [ options: SUBSCRIBE_OPTIONS, }, Subscription { - topic_filter: topic::fan_controller::fan_1::COMMAND, + topic_filter: topic::fan_controller::fan_1::on::COMMAND, options: SUBSCRIBE_OPTIONS, }, Subscription { - topic_filter: topic::fan_controller::fan_1::STATE, + topic_filter: topic::fan_controller::fan_1::percentage::COMMAND, options: SUBSCRIBE_OPTIONS, }, Subscription { - topic_filter: topic::fan_controller::fan_2::COMMAND, + topic_filter: topic::fan_controller::fan_2::on::COMMAND, options: SUBSCRIBE_OPTIONS, }, Subscription { - topic_filter: topic::fan_controller::fan_2::STATE, + topic_filter: topic::fan_controller::fan_2::percentage::COMMAND, options: SUBSCRIBE_OPTIONS, }, ]; diff --git a/topic/src/lib.rs b/topic/src/lib.rs index 60acada..1c01442 100644 --- a/topic/src/lib.rs +++ b/topic/src/lib.rs @@ -23,11 +23,16 @@ pub mod fan_controller { use const_format::formatcp; pub const UNIQUE_ID: &str = formatcp!("{OBJECT_ID}/fan-1"); - /// The topic to publish the on/off state of the fan 1 on the fan controller. - pub const STATE: &str = formatcp!("{UNIQUE_ID}/on/state"); - /// The topic to subscribe to for setting the on/off state of the fan 1 on the fan controller. - /// This topic is used by Home Assistant to notify the fan controller to turn on or off the fan. - pub const COMMAND: &str = formatcp!("{UNIQUE_ID}/on/set"); + pub mod on { + use super::UNIQUE_ID; + use const_format::formatcp; + + /// The topic to publish the on/off state of the fan 1 on the fan controller. + pub const STATE: &str = formatcp!("{UNIQUE_ID}/on/state"); + /// The topic to subscribe to for setting the on/off state of the fan 1 on the fan controller. + /// This topic is used by Home Assistant to notify the fan controller to turn on or off the fan. + pub const COMMAND: &str = formatcp!("{UNIQUE_ID}/on/set"); + } pub mod percentage { use super::UNIQUE_ID; @@ -43,11 +48,17 @@ pub mod fan_controller { use const_format::formatcp; pub const UNIQUE_ID: &str = formatcp!("{OBJECT_ID}/fan-2"); - /// The topic to publish the on/off state of the fan 2 on the fan controller. - pub const STATE: &str = formatcp!("{UNIQUE_ID}/on/state"); - /// The topic to subscribe to for setting the on/off state of the fan 2 on the fan controller. - /// This topic is used by Home Assistant to notify the fan controller to turn on or off the fan. - pub const COMMAND: &str = formatcp!("{UNIQUE_ID}/on/set"); + + pub mod on { + use super::UNIQUE_ID; + use const_format::formatcp; + + /// The topic to publish the on/off state of the fan 2 on the fan controller. + pub const STATE: &str = formatcp!("{UNIQUE_ID}/on/state"); + /// The topic to subscribe to for setting the on/off state of the fan 2 on the fan controller. + /// This topic is used by Home Assistant to notify the fan controller to turn on or off the fan. + pub const COMMAND: &str = formatcp!("{UNIQUE_ID}/on/set"); + } pub mod percentage { use super::UNIQUE_ID;