diff --git a/kdash_server/src/handlers.rs b/kdash_server/src/handlers.rs index 83ff1cc..0725188 100644 --- a/kdash_server/src/handlers.rs +++ b/kdash_server/src/handlers.rs @@ -92,6 +92,7 @@ pub async fn post_config( MqttDeviceDiscoveryComponent { platform: "sensor", device_class: "battery", + force_update: true, unit_of_measurement: Some("%"), value_template: "{{ value_json.battery_level }}", unique_id: &unique_id_battery_level, @@ -102,6 +103,7 @@ pub async fn post_config( MqttDeviceDiscoveryComponent { platform: "sensor", device_class: "current", + force_update: true, unit_of_measurement: Some("mA"), value_template: "{{ value_json.battery_current }}", unique_id: &unique_id_battery_current, @@ -112,6 +114,7 @@ pub async fn post_config( MqttDeviceDiscoveryComponent { platform: "sensor", device_class: "voltage", + force_update: true, unit_of_measurement: Some("mV"), value_template: "{{ value_json.battery_voltage }}", unique_id: &unique_id_battery_voltage, diff --git a/kdash_server/src/lib.rs b/kdash_server/src/lib.rs index c0e9cce..5de0947 100644 --- a/kdash_server/src/lib.rs +++ b/kdash_server/src/lib.rs @@ -210,12 +210,16 @@ pub struct MqttDeviceDiscoveryOrigin<'a> { pub struct MqttDeviceDiscoveryComponent<'a> { #[serde(rename = "p")] pub platform: &'a str, + pub device_class: &'a str, + pub force_update: bool, + #[serde(skip_serializing_if = "Option::is_none")] #[serde(default)] pub unit_of_measurement: Option<&'a str>, pub value_template: &'a str, + pub unique_id: &'a str, }