There seems to be an issue with your item definition because openHAB is not allowing the connection from 192.168.1.166.
2017-08-22 22: 25: 07.364 [INFO] [ing.tcp.AbstractSocketChannelBinding] - Received connection request from /192.168.1.166:25108
2017-08-22 22: 25: 07.365 [INFO] [ing.tcp.AbstractSocketChannelBinding] - Disconnecting the unallowed remote end /192.168.1.166:25108
This is not correct. It should look like this:
2017-08-23 20:29:21.184 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - Received connection request from /192.168.0.7:50102
2017-08-23 20:29:21.188 [INFO ] [ing.tcp.AbstractSocketChannelBinding] - 192.168.0.7:* is an allowed masked remote end. The channel will now be configured
Here I’m connecting successfully using telnet from my laptop to my openHAB instance running on a Raspberry Pi.
There seem to be a number of problems with single and double quotes in your item definition. These are not of the correct type.
When editing files, use either the openHAB Designer or Visual Studio Code with the openHAB extension (or notepad, notepad++, nano or vi if you must).
Don’t use Write, Wordpad, Word or any other such kind of program because the tend to ‘beautify’ your text by replacing single and double quotes by more fancy but incompatible versions.
The same holds true for your map file. Here you can spot the incorrect double quotes as well:
ON="{“ObjType”: 0,“Id”: 1,“OnState”: 1,“InvertedState”: 0,“ToggleState”: 0,“Send2”: 0}“
OFF=”{“ObjType”: 0,“Id”: 1,“OnState”: 0,“InvertedState”: 0,“ToggleState”: 0,“Send2”: 0}"
Only the first double qoute is the correct one. The others are all the fancy type.
So tonight I’ve been doing some testing with the following item defintion. Note that 192.168.0.7 is the ip address of my laptop.
Switch Light_Omnimark "OmniMark" (FF_Bed, Lights) {tcp="<[ON:192.168.0.7:*:MAP(omnimark.map)], <[OFF:192.168.0.7:*:MAP(omnimark.map)]"}
And this omnimark.map
file:
{\"ObjType\"\:\ 0,\"Id\"\:\ 1,\"OnState\"\:\ 1,\"InvertedState\"\:\ 0,\"ToggleState\"\:\ 0,\"Send2\"\:\ 0}\r\n=ON
{\"ObjType\"\:\ 0,\"Id\"\:\ 1,\"OnState\"\:\ 0,\"InvertedState\"\:\ 0,\"ToggleState\"\:\ 0,\"Send2\"\:\ 0}\r\n=OFF
ON={"ObjType": 0,"Id": 1,"OnState": 1,"InvertedState": 0,"ToggleState": 0,"Send2": 0}
OFF={"ObjType": 0,"Id": 1,"OnState": 0,"InvertedState": 0,"ToggleState": 0,"Send2": 0}
Using telnet I can connect to openHAB on port 8800. When I send the “ON” JSON string then in Basic UI the switch switches to the ON position (after refreshing the page). When I send the “OFF” JSON string then in Basic UI the switch switches to the OFF position (again, after refreshing the page).
When I use Basic UI to send the ON and OFF commands then for some reason I do not see the result in my telnet session. So at first I thought that this didn’t work. However, when tracing with Wireshark I can see that my laptop receives the JSON string from openHAB, so it is working.
In your omnimark.map
file you may need to play with the \r\n
a bit. May be just a \n
will suffice. That all depends on your ESP8266 code. When using telnet I need to append the JSON in the mapping file with \r\n
because telnet appends those characters when I press the enter
key.
That all said, I would strongly suggest that you take the advice Rich gave and use MQTT instead.
Good luck!