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>,
pub color_temperature: Option<u16>,
}
impl From<huelib::resource::light::State> for State {
fn from(value: huelib::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,
pub name: String,
#[serde(flatten)]
pub state: State,
}
impl From<huelib::resource::light::Light> for Light {
fn from(value: huelib::resource::light::Light) -> Self {
Self {
id: value.id,
name: 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<huelib::resource::group::Group> for Room {
fn from(value: huelib::resource::group::Group) -> Self {
Self {
name: value.name,
lights: value.lights,
}
}
}