Hey all,
I’m working on trying to control some devices with OpenHAB2 that can be addressed via telnet/tcp commands. I initially thought about writing my own binding but found that it was going to be too much work for devices that probably noone else would use. See here: https://community.openhab.org/t/bindings-to-send-telnet-commands-av-switcher-and-amx-netlinx-controllers/
So now i’m trying to work out the TCP binding, and am having some difficulty in getting it set up, due to my inexperience with OpenHAB and the lack of documentation available (I know its a work in progress).
Correct my if i’m wrong, but this is what I need to set up to get a binding working in OH2:
/etc/openhab2/services/tcp.cfg = tcp binding configuration file
/etc/openhab2/items/ = define items to control a device
/etc/openhab2/sitemaps/ = define the ‘controls’ that show up in OH, referencing the items that are setup
/etc/openhab2/rules/ = define rules that are used
/etc/openhab2/transform/ = define any mappings
Right?
So for the TCP binding, I need to have the config file set up, then set up an item that has the TCP command (with the syntax shown in the wiki, either in a map/transform or as a string), then reference that item in the site map (with the syntax shown in the wiki)?
Secondly, when the devices are issued a command, they respond with a string to say that the command was received and completed. There are also a number of error strings. How do I go about setting up the TCP binding to handle this? As far as I can figure out there is nothing native in the binding? The only way I thought about doing it was to have a rule that says when an item was switched on or off, to set the tcp binding to receive mode and then update the switch that was activated based on the response received?
How do I go about setting up the binding to check the status of the controls? I can send a status command to the device and it will respond with a code to say what status it is in for that control, do I set that up in a rule as well?
Then, in terms of the items.
For the switcher, I have 12x inputs and 8x outputs. I can go through and have 8 on/off switches for each input (input 1 -> output 1 on/off, input 1 > output 2 on/off etc), but i would end up with pages and pages of switches. Or I could have a multi value switch for each of the 8 outputs to say which input is going to it (ie output 1 is either input 1/2/3/4 etc). I can’t see any mention of a way to do multi value switch? The best way I can find to do this is to have items set up as a Number type for the inputs (1->12), and then in the sitemap have 8 switches for each output that has 12 values per switch? May need to have a map or rule so that it sends the right command?
Then I also have some volume sliders, and the command that sends a value from 1 to 64, so I would just use a rule/transform to convert the openhab dimmer type switch value to a 1 to 64 value and send that as a command?
Any help would be greatly appreciated!
Cheers,
Alex