use serde::{Deserialize, Serialize};
pub mod room;
pub mod status;
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct State {
pub on: Option<bool>,
pub brightness: Option<u8>,
pub hue: Option<u16>,
pub saturation: Option<u8>,
#[serde(skip_serializing_if = "Option::is_none")]
pub color_temperature: Option<u16>,
}
impl From<huelib2::resource::light::State> for State {
fn from(value: huelib2::resource::light::State) -> Self {
Self {
on: value.on,
brightness: value.brightness,
hue: value.hue,
saturation: value.saturation,
color_temperature: value.color_temperature,
}
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct Light {
pub id: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(flatten)]
pub state: State,
}
impl From<huelib2::resource::light::Light> for Light {
fn from(value: huelib2::resource::light::Light) -> Self {
Self {
id: value.id,
name: Option::from(value.name),
state: value.state.into(),
}
}
}
#[derive(Clone, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)]
pub struct Room {
pub name: String,
pub lights: Vec<String>,
}
impl From<huelib2::resource::group::Group> for Room {
fn from(value: huelib2::resource::group::Group) -> Self {
Self {
name: value.name,
lights: value.lights,
}
}
}