parent
e86eee3984
commit
35c7a5c0e5
|
@ -46,6 +46,14 @@ func (c *HatsClient) GetState(entityId string) (string, error) {
|
||||||
return resp.String(), nil
|
return resp.String(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *HatsClient) GetStateWithDefault(entityId string, defaultValue string) string {
|
||||||
|
state, err := c.GetState(entityId)
|
||||||
|
if err != nil {
|
||||||
|
return defaultValue
|
||||||
|
}
|
||||||
|
return state
|
||||||
|
}
|
||||||
|
|
||||||
func (c *HatsClient) GetStateBool(entityId string) (bool, error) {
|
func (c *HatsClient) GetStateBool(entityId string) (bool, error) {
|
||||||
stateString, err := c.GetState(entityId)
|
stateString, err := c.GetState(entityId)
|
||||||
|
|
||||||
|
|
|
@ -38,23 +38,25 @@ var Domains = struct {
|
||||||
|
|
||||||
// Home Assistant services
|
// Home Assistant services
|
||||||
var Services = struct {
|
var Services = struct {
|
||||||
TurnOn string
|
TurnOn string
|
||||||
TurnOff string
|
TurnOff string
|
||||||
Toggle string
|
Toggle string
|
||||||
Reload string
|
Reload string
|
||||||
Lock string
|
Lock string
|
||||||
Unlock string
|
Unlock string
|
||||||
OpenCover string
|
OpenCover string
|
||||||
CloseCover string
|
CloseCover string
|
||||||
|
SelectOption string
|
||||||
}{
|
}{
|
||||||
TurnOn: "turn_on",
|
TurnOn: "turn_on",
|
||||||
TurnOff: "turn_off",
|
TurnOff: "turn_off",
|
||||||
Toggle: "toggle",
|
Toggle: "toggle",
|
||||||
Reload: "reload",
|
Reload: "reload",
|
||||||
Lock: "lock",
|
Lock: "lock",
|
||||||
Unlock: "unlock",
|
Unlock: "unlock",
|
||||||
OpenCover: "open_cover",
|
OpenCover: "open_cover",
|
||||||
CloseCover: "close_cover",
|
CloseCover: "close_cover",
|
||||||
|
SelectOption: "select_option",
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extra props that can be sent when calling a Home Assistant service
|
// Extra props that can be sent when calling a Home Assistant service
|
||||||
|
|
Loading…
Reference in New Issue