1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Ethernet Relay: PHP or Python Script

Discussion in 'Relay Modules' started by Lox, Feb 5, 2017.

  1. Lox

    Lox New Member

    Joined:
    Feb 5, 2017
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Gender:
    Male
    Location:
    Germany
    Hi Numato-Team,

    can you provide a example script in php (best) or python (also ok) on how to get logged in and at least one command (like open/read Relay 1) over TELNET? All i tried so far just failed at the login (i managed to connect via php-script using "fsockopen()" but only got to the point where password is asked).

    I just got the 32-Channel-Ethernet-Relay (http://numato.com/32-channel-ethernet-relay-module/) and was hoping for an easy way to implement in my whole php-based system like using simple http-Get requests incl the username/pass and a command like the user here asked: https://phpstack-776178-2640993.clo...-to-activate-a-relay-with-an-html-request.81/

    Web interface and normal connection via TELNET-Client (used Putty) works great and fast with the board. But i need to implement all in my system.

    Hoping for good news.
    Best regards,
    Lox
     
  2. Lox

    Lox New Member

    Joined:
    Feb 5, 2017
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Gender:
    Male
    Location:
    Germany
    Hi Numato-Team,

    good news. I just managed to build a small python-script, that is working with the basics to login and open a relay via telnet. Problem with my first attempt was, that i missed to send the commands as ".encode("ascii")". As soon as i got some time, i will recreate the code with some comments and provide it to you. Maybe you want to put it on your downloadsection/git. Guess there are some more people looking for that.

    Best Regards,
    Lox
     
  3. Nikolay

    Nikolay New Member

    Joined:
    Mar 2, 2018
    Messages:
    1
    Likes Received:
    1
    Trophy Points:
    1
    Gender:
    Male
    Location:
    US
    First I would like to say that I am very disappointed with TCP/IP controls available in this board. We have purchased over 20 of these to control shades in the building, and I spent hours trying to figure out why 'telnet' works and regular TCP connection that supplies same user name and password does not. It turned out that board send incorrect command (may be only Windows Telnet correct) to disable local echo while entering password, and do expect just some 3 garbage character + actual password back:

    $ nc X.X.X.X 23
    Numato Lab 16 Channel Ethernet Relay Module
    Enter your user name and password to login
    User Name: admin
    Password: ��-123admin

    Logged in successfully

    >

    if just 'admin' provided it constantly failing with 'Access denied'

    later commands has to be terminated with '\r\n' otherwise board silently accept them without doing anything.

    Web control does not provide any discrete way of switching relay. e.g. http://X.X.X.X/relays.cgi?relay=3 - does both on/off.
    Should be something like relay.cgi?relay=3&mode=[open|close],

    Would be also nice to have something like &pulse=[MSec]. So it would close/open for certain amount of time.

    Bottom line this as it is right now is not developed for any real automation system. Who use manual access over telnet/Web in real life applications ?
    Is this your vision of automation ? I would rather use wall switches at least it is cheaper then having computer and then go to Web page
    to press same buttons there.
     
    chaka likes this.

Share This Page