From e4e666993dcba67a21791b7411bd3886f81d98da Mon Sep 17 00:00:00 2001 From: Maciej Gierada Date: Fri, 12 Jan 2024 22:27:53 +0100 Subject: [PATCH] feat: add humidifier to devices --- src/constants/enums.rs | 1 + src/services/light_setup_service.rs | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/constants/enums.rs b/src/constants/enums.rs index b9f756e..61c996e 100644 --- a/src/constants/enums.rs +++ b/src/constants/enums.rs @@ -9,4 +9,5 @@ pub enum OfficeDevices { StandingLeftLED(Device), WindowLED(Device), BoardLED(Device), + Humidifier(Device), } diff --git a/src/services/light_setup_service.rs b/src/services/light_setup_service.rs index 6518d4e..a4fb1a6 100644 --- a/src/services/light_setup_service.rs +++ b/src/services/light_setup_service.rs @@ -79,6 +79,19 @@ impl OfficeDevices { }; OfficeDevices::WindowLED(window_led) } + + pub fn humidifier() -> Self { + let office_humidifier_id= + env::var("OFFICE_HUMIDIFIER_ID").expect("OFFICE_HUMIDIFIER_ID must be set"); + let office_humidifier_model = + env::var("OFFICE_HUMIDIFIER_MODEL").expect("OFFICE_HUMIDIFIER_MODEL must be set"); + let humidifier = Device { + device_id: office_humidifier_id, + model: office_humidifier_model, + }; + OfficeDevices::WindowLED(humidifier) + } + } pub fn office_setup(device: &OfficeDevices, command: &str) -> PayloadBody { @@ -112,5 +125,10 @@ pub fn office_setup(device: &OfficeDevices, command: &str) -> PayloadBody { model: standing_left_led.model.clone(), cmd: command, }, + OfficeDevices::Humidifier(humidifier) => PayloadBody { + device: humidifier.device_id.clone(), + model: humidifier.model.clone(), + cmd: command, + }, } }