I have an RPS-NODE-9255 that accepts telnet commands to turn the outlet on and off and provides positive confirmation of the outlet’s status.
The following is the putty console history including the commands I’d like to send:
9255ProTelnet command shell
Please input username and password!
9255ProTelnet-> admin:12345678
Username and password is ok!
Type 'help' and return for help
9255ProTelnet-> setpower P61=0
Power Status : 0
9255ProTelnet-> setpower P61=1
Power Status : 1
9255ProTelnet->
How would I go about implementing a thing/item/rule/script for this in openhab? Which binding should I use to spawn a telnet session each time I want to change the outlet status?
I think the TCP/UDP binding would be able to support telnet but I’m not certain. If not I’m not sure if there is any binding at this time that can do it. Since the TCP/UDB binding is a v1 binding, there will not be any Things and you will have to configure your Items using .items files. See https://www.openhab.org/addons/bindings/tcp1/ for details.
The challenging thing is this binding isn’t designed to be quite so interactive like that so this is going to require a lot of Rules.
I’m developing a binding for my personal use that tracks my ip numbers and keep my wan side access open if they change. One part of that binding is to log in and send few ip6tables/ebtables rules to my router through telnet. For now i’m using apache.commons.net.telnet library that seems to function very well. I’f you want to develop something on your own I’d suggest to start there. Or if youre not in a hurry maybe I can arrange some free time and fix up a basic telnet binding to send comands and receive output. After that you’d use rules to send the specific commands.
There seems to be a web server/api also implemented in that thing. So there’s possibility to use the http binding or send http commands through rules directly.
You are correct. There is a web server with a visual interface with changeable settings on the RPS box.
As for the HTTP commands, I’m still learning how to get them working. So far, I haven’t been successful with any of the given commands with their template: https://login:password@ipaddress:port/command
The only response I get in a browser is a cookie timeout.
What would the HTTP binding item configuration look like for this? Does the “command” stay in the url or is it put into the HTTP binding’s command parameter?
And for activating the switch, I attempted to link my item to the ping “control” when I added the RPS as a network “thing.” Does that make any sense?
So the logging in with browser works and you can send commands? But not sending direct commands e.g with curl? (Assuming you’re using linux)
Sorry but can’t help you here. I’m not familiar with the http binding but I’m under the impression that it’s mostly used for getting information and not sending. So it probably won’t fit your needs.
I didn’t quite get you here. You’re using network binding maybe and tried to send a command with that? If I understood you correctly then that doesn’t make sense. Ping is very much different than sending POST/GET request.
You have any coding/scripting skills so that you could write a bash/python/perl script that sends those commands? Then you could call that script from openHAB with exec binding as @Thedannymullen suggested. Of course my initial proposal still stands.
@Tim_Travis these Actions that Rich mentioned might be useful to you. Check them out and write a rule using those. Searching with “sendHttpPostRequest” and “sendHttpGetRequest” gives nice results for starters
here is my rule for triggering the item to switch state:
rule "rps_on"
when
Item rps_command changed from OFF to ON
then
rps_command.sendCommand("admin:12345678
setpower P61=1
exit")
end
rule "rps_off"
when
Item rps_command changes from ON to OFF
then
rps_command.sendCommand("admin:12345678
setpower P61=0
exit")
end
As you can see, I’ve included returns in my code for where a carriage return should be sent via telnet. However, I’m not seeing the outlet change state. Is there a way to send carriage reurns via telet? I’ve tried “CR NL”, “CR NUL”, and “\n”.
I’m just confused that when I “showlogs” for openhab, it gives me this:
2019-05-04 01:14:49.554 [nt.ItemStatePredictedEvent] - rps_command predicted to become NULL
First of all I don’t know why you are using Denon Marantz binding to control your device which is a different product. Docs does state that it uses telnet but I think those are denon specific commands.
You’re trying to send a String to a switch channel.