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 CallServiceInput
- type Event
- type EventData
- type HassMessage
- type RestClient
- func (c *RestClient) CallService(entityId string, service string, extras ...map[string]any) error
- func (c *RestClient) CallServiceManual(domain string, entityId string, service string, extras ...map[string]any) error
- func (c *RestClient) CallServices(inputs ...*CallServiceInput) error
- func (c *RestClient) GetState(entityId string) (StateData, error)
- func (c *RestClient) GetThermostatState(entityId string) (output ThermostatState, err error)
- func (c *RestClient) SetThermostatFanMode(entityId string, mode ThermostatFanMode) error
- func (c *RestClient) SetThermostatState(entityId string, desiredState ThermostatState) error
- type Result
- type ResultContext
- type StateData
- type SubscribeEventsMessage
- type ThermostatFanMode
- type ThermostatMode
- type ThermostatState
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 FanMode string Temperature string TargetTempHigh string TargetTempLow string Duration string Value string Position string }{ Transition: "transition", Brightness: "brightness", BrightnessPercent: "brightness_pct", BrightnessPercentStep: "brightness_step_pct", HvacMode: "hvac_mode", FanMode: "fan_mode", Temperature: "temperature", TargetTempHigh: "target_temp_high", TargetTempLow: "target_temp_low", Duration: "duration", Value: "value", Position: "position", }
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 StopCover string SelectOption string SetHvacMode string SetFanMode string SetTemperature string SetValue string Start string Change string Cancel string SetCoverPosition string }{ TurnOn: "turn_on", TurnOff: "turn_off", Toggle: "toggle", Reload: "reload", Lock: "lock", Unlock: "unlock", OpenCover: "open_cover", CloseCover: "close_cover", StopCover: "stop_cover", SelectOption: "select_option", SetHvacMode: "set_hvac_mode", SetFanMode: "set_fan_mode", SetTemperature: "set_temperature", SetValue: "set_value", Start: "start", Change: "change", Cancel: "cancel", SetCoverPosition: "set_cover_position", }
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", "opening", "unlocked", "playing", "active", "good", "walking", "charging", "alive", "heat", "heat_cool", "cool", "above_horizon", numbers > 0 All others return false
Types ¶
type AuthMessage ¶
type CallServiceInput ¶
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 ¶
func (*RestClient) CallServices ¶
func (c *RestClient) CallServices(inputs ...*CallServiceInput) error
func (*RestClient) GetThermostatState ¶
func (c *RestClient) GetThermostatState(entityId string) (output ThermostatState, err error)
func (*RestClient) SetThermostatFanMode ¶
func (c *RestClient) SetThermostatFanMode(entityId string, mode ThermostatFanMode) error
func (*RestClient) SetThermostatState ¶
func (c *RestClient) SetThermostatState(entityId string, desiredState ThermostatState) error
type Result ¶
type Result struct {
Context ResultContext `json:"context,omitempty"`
}
type ResultContext ¶
type ResultContext struct {
Id string `json:"id,omitempty"`
}
type SubscribeEventsMessage ¶
type ThermostatFanMode ¶
type ThermostatFanMode string
const ThermostatFanModeAuto ThermostatFanMode = "Auto low"
const ThermostatFanModeLow ThermostatFanMode = "Low"
type ThermostatMode ¶
type ThermostatMode string
const ThermostatModeCool ThermostatMode = "cool"
const ThermostatModeHeat ThermostatMode = "heat"
const ThermostatModeHeatCool ThermostatMode = "heat_cool"
const ThermostatModeOff ThermostatMode = "off"
type ThermostatState ¶
type ThermostatState struct { Mode ThermostatMode FanMode ThermostatFanMode TargetTempHigh float64 TargetTempLow float64 }
Click to show internal directories.
Click to hide internal directories.