Closed Tadzikj closed 6 years ago
mqtt is not supported in this simple script. You can use the http-binding to use the http in your openhab items-configfile. (https://github.com/openhab/openhab1-addons/wiki/Http-Binding)
When the Http-Binding is installed, you can use it like this:
Switch MyItem1 { http=">[ON:POST:http://{ip-form-configfile:port}/devices/{deviceId}/on] >[OFF:POST:http://{ip-form-configfile:port}/devices/{deviceId}/off]" }
you can get the deviceId with a simple query to http://{ip-form-configfile:port}/devices
@Tadzikj did this help you? if so, i would like to close this issue.
Hello.
I am sorry that it was only now but I could not make it earlier
I solved the problem by installing the server in openhb in the item file I placed the switch entry
Switch testsonoff1 "test S20 sonoff1 10000dxxaab" {exec="ON:curl http://192.168.1.196:1081/devices/10000dxxaab/on,OFF:curl http://192.168.1.196:1081/devices/10000dxxaab/off" }
String testsonoff1_state "S20 10000dxxaab: [% s]" {http = "<[http: // IP: 1081 / devices / 10000dxxaab: 5000: JSONPATH ($ .state)]"}
and he's laughing additionally, in the rules file I have placed the code which reads the state after manual change to sonoff (use of the device on the device)
rule "JSON sonoff" when Item testsonoff1_state received update then if (testsonoff1_state.state == "on") { postUpdate (testsonoff1, "ON") } else { postUpdate (testsonoff1, "OFF") } end
Thank you for your help
I greet and wish you a Happy New Year
Welcome.
How to connect to openhab and mqtt?
Regards. Tadzik