From: Tim Harper Date: Tue, 27 Dec 2022 09:25:28 +0000 (-0700) Subject: [tplinksmarthome] Document sending raw commands to devices (#14062) X-Git-Url: https://git.basschouten.com/?a=commitdiff_plain;h=e5f30b1f18ea6d5d1215f1bb20c1052a78084e42;p=openhab-addons.git [tplinksmarthome] Document sending raw commands to devices (#14062) Signed-off-by: Tim Harper Signed-off-by: Tim Harper --- diff --git a/bundles/org.openhab.binding.tplinksmarthome/README.md b/bundles/org.openhab.binding.tplinksmarthome/README.md index 2facf96037..9df31724c8 100644 --- a/bundles/org.openhab.binding.tplinksmarthome/README.md +++ b/bundles/org.openhab.binding.tplinksmarthome/README.md @@ -439,3 +439,24 @@ Color TP_LB_Color "Color" { channel="tplink Switch TP_LB_ColorS "Switch" { channel="tplinksmarthome:lb130:bulb2:color" } Switch TP_O_OUTLET "Outdoor Outlet" { channel="tplinksmarthome:kp401:outlet:switch" } ``` + +## Sending Raw Commands to Devices (Advanced Usage) + +TPLinkSmarthome Things can be sent a raw JSON string to control a device in a way not directly supported by this binding. +You can find several JSON commands in the [test fixtures](https://github.com/openhab/openhab-addons/tree/main/bundles/org.openhab.binding.tplinksmarthome/src/test/resources/org/openhab/binding/tplinksmarthome/internal/model) for this binding. + +As an example, you might want to change the brightness level of a dimmer without turning it on or off. +Given the dimmer Thing has an id of `tplinksmarthome:hs220:123ABC`, you could accomplish just that with the following rule: + +`example.rules` + +```java +rule "Directly set the dimmer level when desired dimmer level changes, without turning the light on/off" +when + Item Room_DesiredDimmerLevel changed +then + val cmd = '{"smartlife.iot.dimmer":{"set_brightness":{"brightness":' + Room_DesiredDimmerLevel.state + '}}}' + val actions = getActions("tplinksmarthome", "tplinksmarthome:hs220:123ABC") + actions.send(cmd) +end +```