[SOLVED] .map file not working TCP command

I might be fundamentally not understanding something, but I"m using the TCP binging to send a command to a ethernet relay.

this works:

Switch Light_map “Light_map” {tcp=“>ON:xx.xx.xx.xx:1234:L1], >[OFF:xx.xx.xx.xx:1234:D1]”}

The commands are L1 for on and D1 for off. this works fine with my switch in sitemaps.
this was just for testing purposes, i’m trying to create a mapping.

Switch Light_map “Light_map” {tcp=“>ON:xx.xx.xx.xx:1234:MAP(tcprelay.map)], >[OFF:xx.xx.xx.xx:1234:MAP(tcprelay.map)]”}

tcprelay.map file

ON=L1
OFF=D1

It seems pretty simple, but does not work. i’m missing something obvious?

Map transformation binding is installed, btw.

thanks much++

I think you do need the single quotes as shown in docs examples.
You could also replace ON/OFF with *

Switch Light_map “Light_map” {tcp=">*:xx.xx.xx.xx:1234:'MAP(tcprelay.map)']}

Sorry, yeah, my post was just a case of bad typing, it’s actually in my .items file as you suggested. I ended up rebooting and it works ok now.
Also made the change to {tcp=">*:xx.xx.xx.xx:1234:‘MAP(tcprelay.map)’]} as you suggested, instead of the two separate commands. works as expected.

Now for the return response errors I’m getting :wink:

My return response from my relay board is “Relayon 1” . I’ve added

“Relayon\ 1=Relay 1 is on” also tried “Relayon 1 = Relay 1 is on”

the backslash accounting for the space character.
to my tcprelay.map file

I’m getting an error

“Could not transform 'Relayon 1” with the file tcprelay.map : Target value not found in map for “Relayon 1”

I don’t really understand how to properly process the return values.

Is there a “TCP binding for dummies ;-)”

This part isn’t about TCP binding, really.

Perhaps your returned message includes invisible characters, like a line feed.
You might, for investigation, temporarily link your inbound TCP to a String type Item so that you can properly examine it in a rule.

EDIT - is that the exact message? I ask because a map-misfire log usually comes with single quotes around the offending text. Maybe the text has quotemarks in it.

Use of a slash to escape a space is the correct form for MAP.
May we see the whole Item and map config now?

However, do note if you are trying to link your incoming TCP to the same Item that you are sending the command from … it’s a Switch type Item. You need your MAP to yield up ON or OFF only.
You’d probably also want to make autoupdate false if you are using the Item in this way.

You can use MAP in a different way in the label to make state ON into text “Relay is on” or whatever for display only.

tcprelay.items

Switch Light_map “Light_map” {tcp=“>[*:192.168.11.166:1234:MAP(tcprelay.map)]”}
String relayin “relayin” {tcp=“<[192.168.11.166:1234:MAP(tcprelay.map)]”}

I added an inbound linked to a string, although I’m not getting anything coming in?

tcprelay.map

ON=L1
OFF=D1
Relayon\ 1=ON

log

[orm.AbstractFileTransformationService] - Could not transform ’

Relayon 1’ with the file ‘tcpoff.map’ : Target value not found in map for ’

Relayon 1’

interestingly enough, now looking at it, as I cut and paste the error, It looks as though there might be a “linebreak” before the response, as there is a line break after the ’

huh, how to deal with that in the .map file?

Alright, I don’t know enough about this stuff to know if a command-respons is handled differently to an unsolicited incoming message.

Temporarily using a test String Item to send command, with no map involved, should allow capture of this response. Command “L1” to this Item etc.
Alternatively, trial and error with the map …

Okay

Uhh … different map file??

Yup.
Odd to put it before, maybe it’s some other control.character(s).

You might be able to put the newline into map as escapes, combinations of \n, \r, \n\r would be favourites.

yeah, the different map file name, tcpoff.map is the actual name of the map file, I just changed it in my post to tcprelay.map just for clarity sake. sorry, I need to pay more attention to my posting edits.

I fired up my packet sniffer to see what was going on. yup, the response from the device is:

\r\nRelayon 1
which is an odd response in my opinion. but hey, who am I to judge :wink:

putting this in my map file works:

\r\nRelayon\ 1=ON

thanks for the reminder to check for hidden characters, got me thinking in the right direction.

1 Like

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.