Add second remote
This commit is contained in:
parent
48c58b610c
commit
8cde891ba2
8 changed files with 51 additions and 11 deletions
|
|
@ -83,6 +83,8 @@ let lights =
|
|||
|
||||
let remoteControlFriendlyName = DeviceFriendlyName "Fjärrkontroll"
|
||||
|
||||
let livingRoomRemoteControlFriendlyName = DeviceFriendlyName "Living Room Remote"
|
||||
|
||||
type internal State =
|
||||
| On
|
||||
| Off
|
||||
|
|
|
|||
|
|
@ -111,6 +111,14 @@ type NightLightStateMachine private (maybeState: NightLightState option) =
|
|||
currentState
|
||||
|> withInvertedStateFor LivingRoomWallLamp
|
||||
|> withInvertedStateFor LivingRoomFloorLamp
|
||||
| PressedLivingRoomOn ->
|
||||
currentState
|
||||
|> withStateFor LivingRoomWallLamp On
|
||||
|> withStateFor LivingRoomFloorLamp On
|
||||
| PressedLivingRoomOff ->
|
||||
currentState
|
||||
|> withStateFor LivingRoomWallLamp Off
|
||||
|> withStateFor LivingRoomFloorLamp Off
|
||||
|
||||
NightLightStateMachine(Some newNightLightState),
|
||||
generateZigbeeCommandsForDifference (Some currentState) newNightLightState
|
||||
|
|
|
|||
|
|
@ -15,8 +15,7 @@ let generateStateCommand state light =
|
|||
| On -> "ON"
|
||||
| Off -> "OFF"
|
||||
|
||||
if (lightProps light).Bulb = IkeaBulb then
|
||||
commandObj["transition"] <- 0
|
||||
commandObj["transition"] <- 0
|
||||
|
||||
commandObj.ToJsonString() |> toZigbeeCommand light
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ type Action =
|
|||
| PressedOff
|
||||
| PressedLeft
|
||||
| PressedRight
|
||||
| PressedLivingRoomOn
|
||||
| PressedLivingRoomOff
|
||||
|
||||
type ZigbeeEvent =
|
||||
| DeviceAnnounce of DeviceFriendlyName
|
||||
|
|
@ -41,5 +43,12 @@ let parseZigbeeEvent (message: Message) =
|
|||
| Some(JsonValue.String "arrow_right_click") -> Ok(ButtonPress PressedRight)
|
||||
| Some _ -> Error InvalidActionField
|
||||
| None -> Error MissingActionField
|
||||
| "zigbee2mqtt/Living Room Remote" ->
|
||||
return!
|
||||
match jsonValue.TryGetProperty "action" with
|
||||
| Some(JsonValue.String "on") -> Ok(ButtonPress PressedLivingRoomOn)
|
||||
| Some(JsonValue.String "off") -> Ok(ButtonPress PressedLivingRoomOff)
|
||||
| Some _ -> Error InvalidActionField
|
||||
| None -> Error MissingActionField
|
||||
| _ -> return! Error <| UnknownTopic message.Topic
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue