Hello, I have a Wemo smart plug that has an energy (power) monitor, which returns a Number of watts being consumed by the connected load. I would like to forward this value to a remote system via TCP when it changes.
I have an Item set up with a TCP binding and linked to the Thing, but it does not call the TCP binding when value changes. The TCP works when commanded - but that’s not the event that happens when the Thing value is updated.
When the Wemo binding reads the value, the log records an “ItemStateChangedEvent” and the value is displayed on HABmin correctly. But no TCP transmission.
I suspected that the behavior may be different if the Item was Commanded rather than just having a StateChange.
I tested this by using the REST API documentation with a POST (Command) vs. a PUT (StateChange). When the item received a Command, the TCP was called and the value was received by the remote system. When I used the PUT (State Change), the TCP transmission did not occur (but the value still displays properly in HABmin)
Here is my Item:
Number iWasherPower "Washer Power is [%d]" { tcp=">[192.168.76.21:7777:default]" }
and the DEBUG when the service starts:
2016-12-18 22:20:52.829 [DEBUG] [ing.tcp.AbstractSocketChannelBinding] - Setting up the outbound assigned channel C hannel [item=iWasherPower, command=0, direction=OUT, remote=/192.168.76.21:7777, buffer=, isBlocking=false, isRecon necting=false, channel=::/192.168.76.21:7777, host=192.168.76.21, port=7777]
2016-12-18 22:20:52.832 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - The channel for /192.168.76.21:7777 is now connected
In my Item I have tried using an asterisk as the first parameter of the TCP argument (prior to the 192, with a colon) as the asterisk is supposed to 'catch; all commands. Even though the DEBUG of the startup changes command=0 to command=*, the results are the same.
Here is the DEBUG when the Item receives a Command (POST) (I sent the number ‘2’)
2016-12-18 22:25:40.717 [DEBUG] [ing.tcp.protocol.internal.TCPBinding] - transformed response is '2'
2016-12-18 22:25:40.855 [DEBUG] [ing.tcp.AbstractSocketChannelBinding] - Picked WriteBufferElement [Channel=Channel [item=iWasherPower, command=0, direction=OUT, remote=/192.168.76.21:7777, buffer=, isBlocking=false, isReconnectin g=false, channel=/192.168.76.115:38426::/192.168.76.21:7777, host=192.168.76.21, port=7777], buffer=2
, isblocking=false] from the queue
2016-12-18 22:25:40.858 [DEBUG] [ing.tcp.AbstractSocketChannelBinding] - Sending 2
for the outbound channel /192.168.76.115:38426->/192.168.76.21:7777
But when the number is updated via the Wemo Binding the Event log reads
2016-12-18 22:43:38.710 [ItemStateChangedEvent ] - iWasherPower changed from 89 to 88
but no TCP transmission and nothing in the DEBUG corresponding to that event.
How can I have the number sent out via TCP when there is a StateChangedEvent?
Thank you