I am trying to set up Sonoff DIY with rest api & http binding
Can someone tell me why the state(switch: on/off) of the device(channel id: switch_trest) is not updated when i use external switch?
I use almost same configuration in channel - id: stateonly and state(switch: on/off) gets updated when i use external switch.
I dont understand why this is happening?
You might find clues in your events.log and/or openhab.log
Does your device really send an empty deviceid field?
Anyway, you appear to have set up to use JSONPATH to extract on/off, then try to match on/off with a longer string of JSON, which isnât going to match.
Hi,
Thanks for your reply.
No my device does return deviceid field but i didnt use it since it worked without it.
Since i dont have much experience on this i did not understand the second part with âthen try to match on/off with a longer string of JSON, which isnât going to match.â
I will read a bit then try to fix this.
I am confused because state of âItem âTest3_stateonlyââ is correct when i press external switch and configuration is the same.
Logs:
2021-08-16 16:18:19.026 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Test3_switchtrest' changed from OFF to UNDEF
2021-08-16 16:18:19.524 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Test3_stateonly' changed from on to off
2021-08-16 16:18:20.796 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'Test3_switchtrest' received command ON
2021-08-16 16:18:20.801 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'Test3_switchtrest' predicted to become ON
2021-08-16 16:18:20.812 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Test3_switchtrest' changed from UNDEF to ON
2021-08-16 16:18:25.170 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Test3_switchtrest' changed from ON to UNDEF
2021-08-16 16:18:25.525 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Test3_stateonly' changed from off to on
2021-08-16 16:18:37.532 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Test3_stateonly' changed from on to off
2021-08-16 16:18:43.705 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Test3_stateonly' changed from off to on
Thanks for your reply.
I donât get it , as i thought it is, is that these values(on, off value) are for turning device on and off, they have nothing to do with the state of the device. But i guess i misunderstood all this.
onValue, offValue are bi-directional.
An outgoing ON/OFF command is transformed to the given string.
An incoming string that matches one is transformed to ON/OFF state update. No match, no work.
I understand now that ON/OFF values should be transformed in other way, or somehow to match those. I will need some example how to do it because i cannot figure this out.
Thanks a lot for you explanation
Thanks a lot you for your help. Working example below
Solution was to change as you said onValue to on and offValue to off.
Also to create a Transform .map(in this case filename âsonoff.mapâ) file with