Ankündigung

Einklappen
Keine Ankündigung bisher.

Relay board controlled over HTTP POST is not working

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • Relay board controlled over HTTP POST is not working

    Hello all,

    I bought this relay board: http://www.aliexpress.com/item/Diffe...636230809.html

    And trying to get it working with using virtual output and POST commands.
    Unfortunately cannot get through. Could somebody help me please?

    I have found this information about how to controll it:
    Default IP is 192.168.1.166, the default HTTP port 80, the default username is admin, the default password is 12345678.
    POST address: http: // admin: 12345678@192.168.1.166/relay.cgi
    parameter: relay1 = on & relay2 = off & relay3 = on & relay4 = off & relay5 = on & relay6 = off & relay7 = on & relay8 = off (Open relay represents 1,3,5,7; 2,4,6,8 Off Relay)
    Factory settings :
    - IP: 192.168.1.166
    - user/password : admin/12345678
    - subnet mask: 255.255.255.0
    - Gateway: 192.168.1.1
    - TCP port : 1234
    - HTTP port : 80
    Control card over http :
    Switching relais : curl --request POST 'http://admin:12345678@192.168.1.166/control.cgi' --data "{command}"
    command = "saida1on=1" > relai 1 on "saida1off=1" > relai 1 off "saida1pluse=1" = pulse relai 1 and so on ...

    I tried to set:
    Virtual output address: http://admin:12345678@192.168.1.166
    http POST comand for ON: relay.cgi?saida1on=1

    but doesn’t work :-(

    When I am controlling relay board through web browser over network (connecting to internal webserver application), it works without any problem
    Am I doing some mistake somewhere?

    Thank you very much for any advice

    Jan

  • #2
    I just got the idea to check what web browser is sending by http. As I mentioned before through web browser, I can control relay board without any problem.
    So here are the data:

    Code:
    POST /relay_en.cgi HTTP/1.1
    Host: 192.168.1.166
    Connection: keep-alive
    Cache-Control: max-age=0
    Authorization: Basic YWRtaW46MTIzNDU2Nzg=
    Origin: http://192.168.1.166
    Upgrade-Insecure-Requests: 1
    User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36
    Content-Type: application/x-www-form-urlencoded
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
    Referer: http://192.168.1.166/relay_en.cgi
    Accept-Encoding: gzip, deflate
    Accept-Language: cs,en-US;q=0.8,en;q=0.6
    Content-Length: 11
    
    saida1on=on
    So I set:
    Virtual output address: http://admin:12345678@192.168.1.166
    http POST comand for ON: relay_en.cgi?saida1on=on

    But no response from miniserver :-(

    Please help!

    Kommentar


    • #3
      Hello Honzappp,

      the POST URL ist different from the POST content/command, so I suggest to try

      http command for ON: /relay_en.cgi
      http POST command for ON: saida1on=on

      My Config is German, so the actual parameter name might be slightly different, but it should not be too complicated to find it.

      From your description of the "manual" I would think that the URL /relay.cgi (or /relay_en.cgi) is different from /control.cgi and the command "saida1on=1" (or is it "saida1on=on" ?) needs the second URL.

      Maybe send a screenshot from the virtual output and virtual output command if you still have problems.

      Cheers,
      Jan
      Miniserver v14.5.12.7, 2x Ext., 2x Relay Ext., 2x Dimmer Ext., DMX Ext., 1-Wire Ext., Gira KNX Tastsensor 3 Komfort, Gira KNX Präsenzmelder, Fenster- und Türkontakte, Loxone Regen- und Windsensor, Gira Dual Q Rauchmelder vernetzt, 1x Relais-Modul
      Loxberry: SmartMeter, MS Backup, CamConnect, Weather4Lox
      Lüftung: Helios KWL EC 370W ET mit Modbus TCP - via Pico-C
      Heizung: Stiebel Eltron WPF 5 cool (Sole-Wasser WP) mit ISG, FB-Heizung mit 18 Kreisen, Erdsonde - via modbus/TCP
      Node-RED: IKEA Tradfri

      Kommentar


      • #4
        Thank you Jan for your answer.
        I have tried to use relay.cgi, relay_en.cgi, control.cgi also saida1on=1 and saida1on=on.

        Nothing works:-(

        Kommentar


        • #5
          Do you have an option to capture packets to see what's going on, e.g. by using a port mirroring on your switch? If not, you may do the following as a workaround:
          - install Wireshark on your PC
          - capture packets when you send http commands via web browser to your board
          -> this is your reference

          - install a web server on your PC, no content/files required, but a service that listens to TCP port 80
          - change the IP-address in Loxconfig to your PC
          - capture packets with Wireshark on your PC
          - trigger the virtual output
          -> compare the results. Of course the response from your webserver is completely different to the relay board, but that does not matter. You should be able to see the TCP 3-way handshake and then the HTTP POST.

          If you have the option to mirror a port on your switch or have access to a Fritz!box (http://<ip-address-of-fritzbox>/html/capture.html) you are able to capture packets with Wireshark directly from your MS to the relay board.

          I hope this will help you to track down the problem.
          Miniserver v14.5.12.7, 2x Ext., 2x Relay Ext., 2x Dimmer Ext., DMX Ext., 1-Wire Ext., Gira KNX Tastsensor 3 Komfort, Gira KNX Präsenzmelder, Fenster- und Türkontakte, Loxone Regen- und Windsensor, Gira Dual Q Rauchmelder vernetzt, 1x Relais-Modul
          Loxberry: SmartMeter, MS Backup, CamConnect, Weather4Lox
          Lüftung: Helios KWL EC 370W ET mit Modbus TCP - via Pico-C
          Heizung: Stiebel Eltron WPF 5 cool (Sole-Wasser WP) mit ISG, FB-Heizung mit 18 Kreisen, Erdsonde - via modbus/TCP
          Node-RED: IKEA Tradfri

          Kommentar


          • #6
            I tried what you recommend Jan.

            I set the address of virtual output to my PC IP, installed some webserver and Wireshark. This is what I got when I pushed button for virtual output several times.
            Unfortunately can't understand the meaning. Could you please help me to identify if Loxone is sending good data?

            Thank you very much for your help.
            Honza

            Kommentar


            • #7
              Gast In your last example, you lost authentication in the URL.
              Possibly the board expects some of the header data (Referer, User Agent).

              I don't understand what the TCP port means in your "documentation".
              Could you try to do a telnet or netcat to IP Port 1234.

              The POST that Jan explained, also from my sight, seems to be correct.

              You also could try the Port 80 POST with curl and the relay_en/saida1on combination.
              Hilfe für die Menschen der Ukraine: https://www.loxforum.com/forum/proje...Cr-die-ukraine

              Kommentar


              • #8
                Christian Fenzl I have removed authentication intentionally as this time, I was not connecting to relay board but to my PC, which I expected will not accept it. Sorry I am really beginner in setting up such a communication :-(

                Regarding TCP, I guess the information from their website (http://www.iotzone.cn/product/14-cn.html) can explain it: we specifically added TCP data communication protocol, more simple and convenient, easier than through a web POST / GET mode, the operation faster response

                Kommentar


                • #9
                  Gast Controlling by TCP would effectively make the communication easier than POST.

                  I would test the port 1234 (if it is already possible with your board), and then ask at the iotzone for the interface specification of the TCP interface.

                  In their download section are some documents about the board, but only available after registration.
                  Hilfe für die Menschen der Ukraine: https://www.loxforum.com/forum/proje...Cr-die-ukraine

                  Kommentar


                  • #10
                    Hi Honzapp,

                    your screenshot from Wireshark shows that the TCP 3-way handshake is not finished. You see the first packet (TCP SYN) repeated a couple of times, but never any response. This indicates that there is no server running on the port - in this case no server on TCP port 80.

                    Just to give you an idea, what you should see I've quickly send the following command via curl to my Internet router (IP-address 192.168.128.1) which is listening to port 80:

                    curl --request POST 'http://admin:12345678@192.168.128.1/control.cgi' --data "saida1on=1"

                    With Wireshark I can see the HTTP request and all the content. Here it's even decoded as HTML

                    Klicke auf die Grafik für eine vergrößerte Ansicht

Name: Bildschirmfoto 2016-09-08 um 18.32.10.png
Ansichten: 4282
Größe: 415,9 KB
ID: 55422

                    The content that I was sending (with curl) might not be correct for your relay board, but it was quicker for me than to try to implement the http input on my MS. If I look into the content it is almost the same as your code from post #2.

                    Try to capture packets from the MS to your PC again with a web server running and compare it to packets that are captured from your PC / web browser to the relay board where you said that this works and you are able to control the relay board.

                    It might be easier to use TCP / Telnet directly as Christian has suggested, but troubleshooting would work the same way. Most of the overhead with HTTP POST is done by the MS already.

                    Cheers,
                    Jan

                    Angehängte Dateien
                    Miniserver v14.5.12.7, 2x Ext., 2x Relay Ext., 2x Dimmer Ext., DMX Ext., 1-Wire Ext., Gira KNX Tastsensor 3 Komfort, Gira KNX Präsenzmelder, Fenster- und Türkontakte, Loxone Regen- und Windsensor, Gira Dual Q Rauchmelder vernetzt, 1x Relais-Modul
                    Loxberry: SmartMeter, MS Backup, CamConnect, Weather4Lox
                    Lüftung: Helios KWL EC 370W ET mit Modbus TCP - via Pico-C
                    Heizung: Stiebel Eltron WPF 5 cool (Sole-Wasser WP) mit ISG, FB-Heizung mit 18 Kreisen, Erdsonde - via modbus/TCP
                    Node-RED: IKEA Tradfri

                    Kommentar


                    • #11
                      Thank you all for trying to help me!
                      As my effort to control relays through POST command failed, I would try the TCP.
                      Unfortunately again, I have no experience.

                      I guess I have to put the Modbusserver into the project and set the address for relay board, which is 192.168.1.166:1234.
                      Then create modbus device. Do I need to set the address somehow or just to keep number 1, which was there as a default.
                      Then create digital actor. Any setting necessary there? just keep command 5-Write single coil?

                      Is that all?

                      Thank you very much for all help

                      BTW, this is the TCP documentation (sorry only translated from Chinese to english by google):
                      2015-11-21
                      TCP Relay Protocol V1.3
                      First, the controller parameters
                      Default IP: 192.168.1.166
                      The default communication port: 1234
                      Currently 8 into eight, not analog.

                      Relay switch operation

                      (1) Open Relay
                      L (n), n = 1: 8, such as the need to open the relay 1, then send the string L1. Board relay will return after the operation
                      Back Relayon 1
                      LA Open all relays

                      (2) Off relay
                      D (n), n = 1: 8, such as the need to turn off the relay 3, the transmitted string D3. Board relay will return after the operation
                      Return
                      Relayoff 1
                      DA closes all relays

                      (3) pulse, the relay opens after the set time delay closed, used to simulate the key operation areas
                      P (n), n = 1: 8, 1 To make the relay generates 1 pulse (Analog 1 button operation), then send characters
                      String P1, the controller returns Press 1
                      Here the delay time can be set http://192.168.1.166/name.cgi tap time on the page;
                      You can also send a command to set the tap times.
                      P (n) = delay_time; n = 1: 8; Returns P (n) = delay_time \ r \ n
                      Such as: Send P1 = 5; return P1 = 5 \ r \ n, 1 open relay delay 5 seconds after shut down, then refresh the page
                      Face http://192.168.1.166/name.cgi, the corresponding parameters have changed, and power-down save.

                      (4) to read the relay status
                      R (n), n = 1: 8, such as the need to read the relay state 1, then send the string R1, the board is returned
                      Relayon 1 or Relayoff 1

                      (5) the burst mode read status
                      Send string DUMP, then returns the status of all relays state and input, and finally OK to knot
                      bundle.

                      (6) Read Input Status
                      I (n), n = 1: 8, If you want to read the input port 1 status, then send the string I1, the board returns IL 1
                      (Low to indicate the external switch is turned off) or IH 1 (high, indicating that the external switch is turned on)
                      If there is input status change, no inquiry will automatically send up bit machine status information.

                      (7) to control all relays setr
                      Send setr00000001, the relay 1 is open, the other relay is closed. 0 disables, 1
                      Open, X indicates no action.
                      For example setr000000X1, 3-8 relay is off, the relay 1 is open, keep the original relay 2
                      The state does not operate.

                      (8) to read the relay status getr
                      Send getr instruction, the controller returns getr11000000
                      Changzhou Ching Ming Electronic Technology Co., Ltd. www.iotzone.cn
                      2

                      (9) Communication Timing
                      PC initiates a TCP connection, if the PC in the 20s there is no data to the controller,
                      The controller interrupts the connection with the host computer. E.g:
                      PC Controller
                      L1 Relayon 1
                      DUMP Relayon 1
                      Relayoff 2
                      Relayoff 3
                      Relayoff 4
                      Relayoff 5
                      Relayoff 6
                      Relayoff 7
                      Relayoff 8
                      IL 1
                      IL 2
                      IL 3
                      IL 4
                      IL 5
                      IL 6
                      IL 7
                      IL 8
                      OK

                      (13) Format
                      All commands to format string after string are / r / n carriage return line feed as the end.
                      Additional protocol V1.2 command:
                      1. The input and output associated command
                      Send "I & O =?", Quotes are not contents of the command, query input and output associated state, the controller returns
                      Press "I & O = 1 \ r \ n" or "I & O = 0 \ r \ n", equal to the input associated with a 1:00 output enable input is equal to 0
                      Associated with the output disabled;
                      Send "I & O = 1", the input can be associated with the controller output, the controller returns "I & O = 1 \ r \ n";
                      Send "I & O = 0", prohibits input associated with the output of the controller, the controller returns "I & O = 0 \ r \ n";
                      After the modification, the corresponding page parameter will also change, and support the power-down save.
                      2. Profiles menu command
                      Send "SCENE =?", Quotes are not contents of the command, query scenarios, the controller returns
                      Press "SCENE1 \ r \ n" or "SCENE = 0 \ r \ n", equal to one profile is enabled, the profile is equal to 0
                      Disallowed;
                      Send "SCENE = 1", the controller enables the scene mode, the controller returns "SCENE = 1 \ r \ n";
                      Send "SCENE = 0", the controller prohibits the scene mode, the controller returns "SCENE = 0 \ r \ n";
                      After the modification, the corresponding page parameter will also change, and support the power-down save.
                      Changzhou Ching Ming Electronic Technology Co., Ltd. www.iotzone.cn
                      3
                      3. Enter the Touch function command
                      Send "TOUCH =?", Quotes are not contents of the command, query point touch input enable state, the controller returns
                      Press "TOUCH = 1 \ r \ n" or "TOUCH = 0 \ r \ n", equal to 1 point touch input is enabled, the touch point is equal to 0
                      Input prohibited;
                      Send "TOUCH = 1", so that input can touch the controller, the controller returns "TOUCH = 1 \ r \ n";
                      Send "TOUCH = 0", prohibits touch input to the controller, the controller returns "TOUCH = 0 \ r \ n";
                      After the modification, the corresponding page parameter will also change, and support the power-down save.
                      4. Enter the trigger function command scenarios
                      Send "INON =?", Quotes are not contents of the command, the query to eight input opening scene, the controller returns
                      Back as follows:
                      INON1 = 1xxxxxxx \ r \ n
                      INON2 = x1xxxxxx \ r \ n
                      INON3 = xx1xxxxx \ r \ n
                      INON4 = xxx1xxxx \ r \ n
                      INON5 = xxxx1xxx \ r \ n
                      INON6 = xxxxx1xx \ r \ n
                      INON7 = xxxxxx1x \ r \ n
                      INON8 = xxxxxxx1 \ r \ n
                      Send "INOFF =?", Quotes are not contents of the command, the query to eight input opening scene, the controller returns
                      Back as follows:
                      INOFF1 = 0xxxxxxx \ r \ n
                      INOFF2 = x0xxxxxx \ r \ n
                      INOFF3 = xx0xxxxx \ r \ n
                      INOFF4 = xxx0xxxx \ r \ n
                      INOFF5 = xxxx0xxx \ r \ n
                      INOFF6 = xxxxx0xx \ r \ n
                      INOFF7 = xxxxxx0x \ r \ n
                      INOFF8 = xxxxxxx0 \ r \ n
                      When setting the scene state, you need to enter the settings one by one, such as setting the trigger input 2 open all relay outputs
                      Out, send
                      INON2 = 11111111 \ r \ n, set up after the success of the controller to return INON2 = 11111111 \ r \ n
                      Such as setting the trigger input 2 OFF all the relays off, the sending
                      INOFF2 = 00000000 \ r \ n, set up after the success of the controller to return INON2 = 00000000 \ r \ n
                      5. Device restart command
                      Sending the device a "restart", note the lowercase letters, the controller returns to "restart after
                      60s \ r \ n "
                      The controller will automatically restart and initialization, operation of the controller to wait for 60 seconds.
                      Changzhou Ching Ming Electronic Technology Co., Ltd. www.iotzone.cn
                      4
                      Contact information
                      Deng Jingli:
                      QQ: 1459557489
                      TEL: 15061962326
                      E-mail: dengjinbo@iotzone.cn
                      Deng workers:
                      QQ: 286115417
                      TEL: 18651957324
                      E-mail: dengzhen@iotzone.cn
                      Problems can always contact us, or you can leave a message to our recommendations in the micro-channel public number.
                      Sweep the micro-channel, pay attention to our official public number

                      Kommentar


                      • #12
                        This is not Modbus communication!
                        It seems to be fairly simple.

                        Create a Virtual Output with address
                        tcp://192.168.1.166:1234

                        Create a Virtual Output Command with
                        Command for ON:
                        L1\r\n
                        Command for OFF:
                        D1\r\n
                        Use as digital output: YES

                        That's it.

                        You have to send an ON state (for example from a switch block), not an impuls.
                        Hilfe für die Menschen der Ukraine: https://www.loxforum.com/forum/proje...Cr-die-ukraine

                        Kommentar


                        • #13
                          So simple? Can't wait to try tonight.
                          Thank you

                          Kommentar


                          • #14
                            TCP works! Thank you very much for your help!

                            Kommentar


                            • #15
                              Interesting board. Do the inputs only work with on/off, or can you also use them in pulse modus?

                              Kommentar

                              Lädt...
                              X