This repository has been archived on 2023-08-29. You can view files and clone it, but cannot push or open issues or pull requests.
automation/integration/zigbee/payload.go
Dreaded_X f13ee65ead
All checks were successful
continuous-integration/drone/push Build is passing
Added light sensor
2022-11-23 01:16:46 +01:00

39 lines
760 B
Go

package zigbee
import "encoding/json"
type OnOffState struct {
State bool
}
func (k *OnOffState) UnmarshalJSON(data []byte) error {
var payload struct {
State string `json:"state"`
}
if err := json.Unmarshal(data, &payload); err != nil {
return err
}
k.State = payload.State == "ON"
return nil
}
type RemoteAction string
const (
ACTION_ON RemoteAction = "on"
ACTION_OFF = "off"
ACTION_BRIGHTNESS_UP = "brightness_move_up"
ACTION_BRIGHTNESS_DOWN = "brightness_move_down"
ACTION_BRIGHTNESS_STOP = "brightness_move_down"
)
type RemoteState struct {
Action RemoteAction `json:"action"`
}
type LightSensorState struct {
Illuminance int `json:"illuminance"`
}