Skip to content

Commit

Permalink
Fix color_mode deprecated wez#289
Browse files Browse the repository at this point in the history
  • Loading branch information
niltrip committed Dec 3, 2024
1 parent c9d2776 commit de4d997
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/hass_mqtt/light.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub struct LightConfig {
pub optimistic: bool,
pub supported_color_modes: Vec<String>,
/// Flag that defines if the light supports color modes.
pub color_mode: bool,
// pub color_mode: bool,
/// Flag that defines if the light supports brightness.
pub brightness: bool,
/// Defines the maximum brightness value (i.e., 100%) of the MQTT device.
Expand Down Expand Up @@ -88,7 +88,7 @@ impl EntityInstance for DeviceLight {
if device_state.kelvin == 0 {
json!({
"state": "ON",
"color_mode": "rgb",
"supported_color_modes": ["rgb"],
"color": {
"r": device_state.color.r,
"g": device_state.color.g,
Expand All @@ -100,7 +100,7 @@ impl EntityInstance for DeviceLight {
} else {
json!({
"state": "ON",
"color_mode": "color_temp",
"supported_color_modes": ["color_temp"],
"brightness": device_state.brightness,
"color_temp": kelvin_to_mired(device_state.kelvin),
"effect": device_state.scene,
Expand Down Expand Up @@ -173,18 +173,18 @@ impl DeviceLight {
};

let mut supported_color_modes = vec![];
let mut color_mode = false;
// let mut color_mode = false;

if segment.is_some() || device.supports_rgb() {
supported_color_modes.push("rgb".to_string());
color_mode = true;
// color_mode = true;
}

let (min_mireds, max_mireds) = if segment.is_some() {
(None, None)
} else if let Some((min, max)) = device.get_color_temperature_range() {
supported_color_modes.push("color_temp".to_string());
color_mode = true;
// color_mode = true;
// Note that min and max are swapped by the translation
// from kelvin to mired
(Some(kelvin_to_mired(max)), Some(kelvin_to_mired(min)))
Expand Down Expand Up @@ -225,7 +225,7 @@ impl DeviceLight {
command_topic,
state_topic,
supported_color_modes,
color_mode,
// color_mode,
brightness,
brightness_scale: 100,
effect: true,
Expand Down

0 comments on commit de4d997

Please sign in to comment.