Homematic: add initialise methods (#6813)

This commit is contained in:
Markus Thierolf 2023-03-13 08:42:01 +01:00 • committed by GitHub
parent a82d6e5417
commit 2763495d67
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -51,6 +51,10 @@ func NewConnection(uri, device, meterchannel, switchchannel, user, password stri
conn.Client.Transport = transport.BasicAuth(user, password, conn.Client.Transport)
}
if err := conn.Init(); err != nil {
return conn, err
}
return conn, nil
}
@ -97,6 +101,12 @@ func (c *Connection) XmlCmd(method, channel string, values ...Param) (MethodResp
return hmr, err
}
// Initialze CCU methods via system.listMethods call
func (c *Connection) Init() error {
_, err := c.XmlCmd("system.listMethods", c.SwitchChannel)
return err
}
// Enabled reads the homematic HMIP-PSM switchchannel state true=on/false=off
func (c *Connection) Enabled() (bool, error) {
res, err := c.XmlCmd("getValue", c.SwitchChannel, Param{CCUString: "STATE"})