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 501775654f
All checks were successful
continuous-integration/drone/push Build is passing
More refactoring, made zigbee2mqtt prefix a config option
2022-11-21 23:47:15 +01:00

35 lines
688 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"`
}