Replies: 4 comments 4 replies
-
|
mildly related convo over here #100
Essentially the process of determining what a product can do is you get the hardware and firmware version of the device and then match it up to an external registry of what that can do https://github.com/lifx/products#determining-capabilities Different libraries have different ways of doing that. I'm not sure exactly how that's done in homeassistant. @Djelibeybi might have a better idea. |
Beta Was this translation helpful? Give feedback.
-
|
There are two commands used to Relays are indxed from 0 to 3, so to get the status of a the first relay attached a switch with the serial {
"command": "query",
"args": {
"matcher": {
"serial": "d073d5123456"
},
"timeout": 10,
"pkt_type": "GetRPower",
"pkt_args": {
"relay_index": 0
}
}
}You'll get a reply that looks like this: {
"results": {
"d073d5123456": {
"payload": {
"level": 65535,
"relay_index": 0
},
"pkt_name": "StateRPower",
"pkt_type": 818
}
}
}The {
"command": "set",
"args": {
"matcher": {
"serial": "d073d5123456"
},
"timeout": 10,
"pkt_type": "SetRPower",
"pkt_args": {
"relay_index": 0,
"level": 0
}
}
}Ignore the response you get from the issuing the command as it usually shows you the previous state. Send a Note that neither the switch nor Photons provides any protection against turning off a relay that is powering a LIFX device, so keep that in mind too. :) |
Beta Was this translation helpful? Give feedback.
-
|
For the CLI, to get the current power level of a relay: lifx lan:attr d073d5123456 GetRPower --silent -- '{"relay_index": 0}' | jq
{
"level": 65535,
"relay_index": 0
}To turn that relay off: lifx lan:attr d073d5123456 SetRPower --silent -- '{"relay_index": 0, "level": 0}' | jq
{
"level": 65535,
"relay_index": 0
}Note the response still says |
Beta Was this translation helpful? Give feedback.
-
|
Also very helpful. Thanks both for your quick response and easy answers. I ran a CURL against the REST and it was practically instant. Great work :) Off: On: Get State: Cheers, |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I'm trying to get my head around the API both REST and lifx cli for the 4 gang switch. I can turn all relays off and on, but I can't seem to trigger individual relays. Has anyone had any experience with it or can point me in the right direction? Ultimately I'm trying to integrate it with HomeAssistant so that I can automate turning on my lights and then controlling the LED's I have on the relay segment (non-lifx).
I have no issue discovering the switch, but I've tried getting my head around the documentation to see if I could query the available options for a device, and can't really get my head around that, if someone could even point me at how to query a device capabilities, I'm sure I could figure out the rest.
Thanks,
Matt
Beta Was this translation helpful? Give feedback.
All reactions