-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
enhancementNew feature or requestNew feature or request
Description
I noticed the documentation doesn't have any example of a State Request. Browsing through the code I noticed there was a structure for state requests. I think it would be nice to have a couple of methods for State() such as GetPoweredState() and IsConnected(). I managed to get the information this way:
stateRequest := c.Client.Device(c.Address, c.Model).State()
// {Code:200 Message:Success Data:{Device:..... Model:H5083 Properties:[map[online:true] map[powerState:off]] Devices:[]}}
rsp, err := c.Client.Run(stateRequest) // govee.GoveeResponse
if rsp.Code != 200 {
err = fmt.Errorf("State request failed: %q", rsp.Message)
} else {
fmt.Println("\tMAC :", rsp.Data.Device)
fmt.Println("\tModel :", rsp.Data.Model)
fmt.Println("\tOnline :", rsp.Data.Properties[0]["online"])
fmt.Println("\tPowered:", rsp.Data.Properties[1]["powerState"])
}
return err
But I am ot sure if that is the proper way, especially the use of Data. Devices[]. I only have ONE Govee device so not much I can experiment with.
Other than that I am pretty satisfied, thanks for sharing this useful library. I know there are others but I tried this one and liked it, so it is the one I am using in my pet home project.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request