SR-201 Ethernet Relay Board HassIO integraiton

image

image

I tried your ideas but they don’t seem to be working on mine.

I can’t tell what the problem is yet. I am not getting any card with switches to even try and turn them on/off

I got it working after all! Took a lot longer than I thought as HassIO UI wasn’t loading after last reboot.

Only thing not resolved is the status of ON or OFF. Will try to find a solution for that too

Hi, I have the same problem with the second relay. every 6/7 minutes it turns ON.
here is my yaml section:

  • platform: telnet
    switches:
    ethernetrelay1:
    resource: “192.168.1.65”
    port: 6722
    command_on: ‘11*’
    command_off: ‘21:0^’
    name: “door”
    command_state: ‘00:0^’
    value_template: ‘{{ value == “10000000” or value == “11000000” }}’

    ethernetrelay2:
    resource: “192.168.1.65”
    port: 6722
    command_on: ‘12:0^’
    command_off: ‘22:0^’
    command_state: ‘00:0^’
    name: “motor”
    value_template: ‘{{ value == “01000000” or value == “11000000” }}’

Any ideas how to fix it?
Thank you.

I ended up following this post after all. It uses command line instead of telnet and it seems to be working so far just fine. I’m not sure why the telnet option isn’t working for me though.

1 Like

Thank you drthanwho, I followed that post and it seems it’s working now :slight_smile:

Oh no, the state is wrong, if I turn relay1 after a while the state of relay2 goes to On also.

I’m having a similar problem too. And then it ends up not letting me turn off relay 2. I think for me it’s because of deleting -q 1 which allowed for a delay to read the response

switch 3:
      platform: command_line
      switches:
        portao:
          command_on: echo -n 11 | nc 192.168.11.100 6722
          command_off: echo -n 21 | nc 192.168.11.100 6722
          command_state: echo -n '00:0^' | nc 192.168.11.100 6722
          value_template: '{{ value == "10000000" or value == "11000000" or value == "11100000" or value == "11110000" or value == "11111000" or value == "11111100" or value == "11111110" or value == "11111111" }}'
          friendly_name: Portão Garagem

    switch 4:
      platform: command_line
      switches:
        luz_portao:
          command_on: echo -n 12 | nc 192.168.11.100 6722
          command_off: echo -n 22 | nc 192.168.11.100 6722
          command_state: echo -n '00:0^' | nc 192.168.11.100 6722
          value_template: '{{ value == "01000000" or value == "11000000" or value == "11100000" or value == "11110000" or value == "11111000" or value == "11111100" or value == "11111110" or value == "11111111" }}'
          friendly_name: Luz Portão Garagem

I put it working see my configuration behind.

garage

Thanks drthanwho, by your suggestion to use command line. :slight_smile:

Hi. I am a big fan of these little boards and have all of them extended to 8 relays with additional 6 relay circuits.
To be able to manage the value template, I added a sed command to directly get the digit matching the channel.
Note that all extended relays are inversed, hence the “2” to switch on the relay 8 in the following example:

- platform: command_line
  scan_interval: 10
  switches:
    # sr201 IP: 192.168.0.129, channel 8, inversed
    fan_outlet:
      command_on: echo -n 28 | nc 192.168.0.129 6722
      command_off: echo -n 18 | nc 192.168.0.129 6722
      command_state: echo -n '00:0^' | nc 192.168.0.129 6722 | sed 's/^.......\(.\)/\1/'
      value_template: '{{ value == "1" }}'

A simpler way to do the first value_template is:
'{{ value[0:1] == "1" }}'

With me the second template failed at first but I got it fixed:

'{{ value[1:2] == "1" }}'

I think the statement means: read two bits from the byte en ignore the first. If you were to use 4 or 8 relays your notation would become quite cumbersome.

For the sixth relay the value_template would be:
'{{ value[5:6] == "1" }}' #Get six bits and ignore the first five.

Hi, There is the possibility to insert a physical button in order to control the relay both from HA and from hardware button?

Do you mean a physical button connected to the HA Rpi or to the relay board itself?

on relay board.

not sure about that unfortunately

Isn’t the command for state just 00? What’s different with using “00:0^”?

Some more info about configuration of the relay board SR-201?
I recently purchased 1 for tests and now looking for more information…

1 Like

What do you want to know?

This is the configuration I have ended up with

- platform: command_line
  scan_interval: 5
  switches:
    floodlight_led:
      command_on: echo -n 11 | nc 192.168.1.100 6722
      command_off: echo -n 21 | nc 192.168.1.100 6722
      friendly_name: LED
    floodlight_main:
      command_on: echo -n 12 | nc 192.168.1.100 6722
      command_off: echo -n 22 | nc 192.168.1.100 6722
      friendly_name: Left

I have personal and car gate. Now they are opened by 2 push-button switches.
So 1 relay i could use for ‘personal gate’ and 2nd for ‘car gate’.
I need to get let’s say 1 second impuls on each relay.
Not sure hot to do that via ‘command_line’. As long pressing the buttons is causing unexpected results on the magnet coils…

O.K. I looked in some instructions, so in my case I should send:

command_on: echo -n 11:1 | nc 192.168.1.99 6722