1
0
Fork 0
hats/pkg/homeassistant/structs.go

186 lines
5.3 KiB
Go
Raw Permalink Normal View History

2023-10-12 17:23:35 +00:00
package homeassistant
// Message types that can be returned from Home Assistants websocket API
var MessageType = struct {
AuthRequired string
AuthOk string
AuthInvalid string
Result string
Event string
ZhaEvent string
2023-11-27 22:59:35 +00:00
ZwaveEvent string
2023-10-12 17:23:35 +00:00
SubscribeEvents string
StateChanged string
TagScanned string
2023-10-18 18:35:46 +00:00
TimerStarted string
TimerFinished string
2023-10-12 17:23:35 +00:00
}{
AuthRequired: "auth_required",
AuthOk: "auth_ok",
AuthInvalid: "auth_invalid",
Result: "result",
Event: "event",
ZhaEvent: "zha_event",
2023-11-27 22:59:35 +00:00
ZwaveEvent: "zwave_js_value_notification",
2023-10-12 17:23:35 +00:00
SubscribeEvents: "subscribe_events",
StateChanged: "state_changed",
TagScanned: "tag_scanned",
2023-10-18 18:35:46 +00:00
TimerStarted: "timer.started",
TimerFinished: "timer.finished",
2023-10-12 17:23:35 +00:00
}
// Home Assistant device domains
var Domains = struct {
2023-11-07 22:55:04 +00:00
Light string
Switch string
Lock string
Cover string
Homeassistant string
Group string
2023-10-12 17:23:35 +00:00
}{
2023-11-07 22:55:04 +00:00
Light: "light",
Switch: "switch",
Lock: "lock",
Cover: "cover",
Homeassistant: "homeassistant",
Group: "group",
2023-10-12 17:23:35 +00:00
}
// Home Assistant services
var Services = struct {
2023-10-16 23:00:08 +00:00
TurnOn string
TurnOff string
Toggle string
Reload string
Lock string
Unlock string
OpenCover string
CloseCover string
SelectOption string
SetHvacMode string
SetFanMode string
SetTemperature string
2023-11-10 23:22:46 +00:00
SetValue string
2023-10-18 18:35:46 +00:00
Start string
Change string
Cancel string
2023-10-12 17:23:35 +00:00
}{
2023-10-16 23:00:08 +00:00
TurnOn: "turn_on",
TurnOff: "turn_off",
Toggle: "toggle",
Reload: "reload",
Lock: "lock",
Unlock: "unlock",
OpenCover: "open_cover",
CloseCover: "close_cover",
SelectOption: "select_option",
SetHvacMode: "set_hvac_mode",
SetFanMode: "set_fan_mode",
SetTemperature: "set_temperature",
2023-11-10 23:22:46 +00:00
SetValue: "set_value",
2023-10-18 18:35:46 +00:00
Start: "start",
Change: "change",
Cancel: "cancel",
2023-10-12 17:23:35 +00:00
}
// Extra props that can be sent when calling a Home Assistant service
var ExtraProps = struct {
2023-11-27 22:59:35 +00:00
Transition string
Brightness string
BrightnessPercent string
BrightnessPercentStep string
HvacMode string
Temperature string
TargetTempHigh string
TargetTempLow string
Duration string
Value string
2023-10-12 17:23:35 +00:00
}{
2023-11-27 22:59:35 +00:00
Transition: "transition",
Brightness: "brightness",
BrightnessPercent: "brightness_pct",
BrightnessPercentStep: "brightness_step_pct",
HvacMode: "hvac_mode",
Temperature: "temperature",
TargetTempHigh: "target_temp_high",
TargetTempLow: "target_temp_low",
Duration: "duration",
Value: "value",
2023-10-12 17:23:35 +00:00
}
type ResultContext struct {
Id string `json:"id,omitempty"`
}
type Result struct {
Context ResultContext `json:"context,omitempty"`
}
type StateData struct {
LastChanged string `json:"last_changed,omitempty"`
LastUpdated string `json:"last_updated,omitempty"`
State string `json:"state,omitempty"`
Attributes map[string]interface{} `json:"attributes,omitempty"`
Context interface{} `json:"context,omitempty"`
}
type EventData struct {
2023-11-27 22:59:35 +00:00
EntityId string `json:"entity_id,omitempty"`
NewState StateData `json:"new_state,omitempty"`
OldState StateData `json:"old_state,omitempty"`
// ZHA
2023-10-12 17:23:35 +00:00
DeviceIeee string `json:"device_ieee,omitempty"`
DeviceId string `json:"device_id,omitempty"`
Command string `json:"command,omitempty"`
Args interface{} `json:"args,omitempty"`
Params interface{} `json:"params,omitempty"`
2023-11-27 22:59:35 +00:00
// NFC
TagId string `json:"tag_id,omitempty"`
// ZwaveJS Scene
Domain string `json:"domain,omitempty"`
NodeID int `json:"node_id,omitempty"`
Endpoint int `json:"endpoint,omitempty"`
CommandClass int `json:"command_class,omitempty"`
CommandClassName string `json:"command_class_name,omitempty"`
Label string `json:"label,omitempty"`
Property string `json:"property,omitempty"`
PropertyName string `json:"property_name,omitempty"`
PropertyKey string `json:"property_key,omitempty"`
PropertyKeyName string `json:"property_key_name,omitempty"`
Value string `json:"value,omitempty"`
ValueRaw int `json:"value_raw,omitempty"`
2023-10-12 17:23:35 +00:00
}
type Event struct {
Data EventData `json:"data,omitempty"`
EventType string `json:"event_type,omitempty"`
TimeFired string `json:"time_fired,omitempty"`
Origin string `json:"origin,omitempty"`
}
type HassMessage struct {
Type string `json:"type"`
Version string `json:"ha_version,omitempty"`
AccessToken string `json:"access_token,omitempty"`
Message string `json:"message,omitempty"`
Success bool `json:"success,omitempty"`
Result Result `json:"result,omitempty"`
EventType string `json:"event_type,omitempty"`
Event Event `json:"event,omitempty"`
Id int `json:"id,omitempty"`
}
type AuthMessage struct {
Type string `json:"type"`
AccessToken string `json:"access_token,omitempty"`
}
type SubscribeEventsMessage struct {
Type string `json:"type"`
EventType string `json:"event_type"`
Id int `json:"id"`
}