Documentation ¶
Index ¶
- Variables
- func BoolToService(entityId string, desiredState bool) string
- func ParseDuration(d string) (time.Duration, error)
- func StateToBool(state string) bool
- type AuthMessage
- type Event
- type EventData
- type HassMessage
- type RestClient
- type Result
- type ResultContext
- type StateData
- type SubscribeEventsMessage
Constants ¶
This section is empty.
Variables ¶
View Source
var Domains = struct { Light string Switch string Lock string Cover string Homeassistant string Group string }{ Light: "light", Switch: "switch", Lock: "lock", Cover: "cover", Homeassistant: "homeassistant", Group: "group", }
Home Assistant device domains
View Source
var ExtraProps = struct { Transition string Brightness string BrightnessPercent string BrightnessPercentStep string HvacMode string Temperature string TargetTempHigh string TargetTempLow string Duration string Value string }{ 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", }
Extra props that can be sent when calling a Home Assistant service
View Source
var MessageType = struct { AuthRequired string AuthOk string AuthInvalid string Result string Event string ZhaEvent string ZwaveEvent string SubscribeEvents string StateChanged string TagScanned string TimerStarted string TimerFinished string }{ AuthRequired: "auth_required", AuthOk: "auth_ok", AuthInvalid: "auth_invalid", Result: "result", Event: "event", ZhaEvent: "zha_event", ZwaveEvent: "zwave_js_value_notification", SubscribeEvents: "subscribe_events", StateChanged: "state_changed", TagScanned: "tag_scanned", TimerStarted: "timer.started", TimerFinished: "timer.finished", }
Message types that can be returned from Home Assistants websocket API
View Source
var Services = struct { TurnOn string TurnOff string Toggle string Reload string Lock string Unlock string OpenCover string CloseCover string SelectOption string SetHvacMode string SetFanMode string SetTemperature string SetValue string Start string Change string Cancel string }{ 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", SetValue: "set_value", Start: "start", Change: "change", Cancel: "cancel", }
Home Assistant services
Functions ¶
func BoolToService ¶
BoolToService converts a boolean into the appropriate service string
For locks: true becomes "unlock" and false becomes "lock" For covers: true becomes "open_cover" and false becomes "close_cover" For all others: true becomes "turn_on" and false becomes "turn_off"
func ParseDuration ¶
Parse a Home Assistant duration in HH:MM:SS format
func StateToBool ¶
StateToBool converts a state string into a boolean
States that return true: "on", "home", "open", "playing", non-zero numbers, etc. All others return false regex: ^(on|home|open(ing)?|unlocked|playing|active|good|walking|charging|alive|heat|cool|heat_cool|above_horizon|[1-9][\d\.]*|0\.0*[1-9]\d*)$
Types ¶
type AuthMessage ¶
type EventData ¶
type EventData struct { EntityId string `json:"entity_id,omitempty"` NewState StateData `json:"new_state,omitempty"` OldState StateData `json:"old_state,omitempty"` // ZHA 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"` // 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"` }
type HassMessage ¶
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 RestClient ¶
type RestClient struct {
// contains filtered or unexported fields
}
func NewRestClient ¶
func NewRestClient(baseUrl, token string) *RestClient
func (*RestClient) CallService ¶
func (*RestClient) CallServiceManual ¶
type Result ¶
type Result struct {
Context ResultContext `json:"context,omitempty"`
}
type ResultContext ¶
type ResultContext struct {
Id string `json:"id,omitempty"`
}
type SubscribeEventsMessage ¶
Click to show internal directories.
Click to hide internal directories.