Logging and really not working light restoration
This commit is contained in:
1 parent
1098be227d
commit
c75fc1a7b9
10 files changed
+180
-151
No files matched your search
@@ -2,7 +2,7 @@
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
module HomeAssistant.Controller.Light.Observation
|
||||
( LightSnapshot(..)
|
||||
( LightObservation(..)
|
||||
, observedLight
|
||||
, lightBrightnessEvent
|
||||
, lightTemperatureEvent
|
||||
@@ -37,17 +37,17 @@ lightTemperatureEvent entityId =
|
||||
where
|
||||
eventTemperature v = v ^? key "event" . key "variables" . key "trigger" . key "to_state" . key "attributes" . key "color_temp_kelvin" . _Integral
|
||||
|
||||
data LightSnapshot = LightSnapshot
|
||||
data LightObservation = LightObservation
|
||||
{ observedOn :: Bool
|
||||
, observedBrightness :: Int
|
||||
, observedTemperature :: Int
|
||||
}
|
||||
deriving (Show, Generic, Eq)
|
||||
instance Serialize LightSnapshot
|
||||
instance Serialize LightObservation
|
||||
|
||||
observedLight :: T.Text -> HASS (Event Value) LightSnapshot
|
||||
observedLight :: T.Text -> HASS (Event Value) LightObservation
|
||||
observedLight entityId = proc ev -> do
|
||||
e <- hold False . entityBool entityId -< ev
|
||||
b <- hold 0 . lightBrightnessEvent entityId -< ev
|
||||
t <- hold 0 . lightTemperatureEvent entityId -< ev
|
||||
returnA -< LightSnapshot e b t
|
||||
returnA -< LightObservation e b t
|
||||
Reference in new issue
Block a user