Extend HLK-SW16 wifi relay module support to smaller cheaper HLK-SW02 & HLK-SW04

Hi,

Hi-Link has two smaller cheaper wifi relay modules:

I would need them to pilot some Electric Air Duct Damper and they are quite cheaper than HLK-SW16 ($56)

Could you please have them supported by HomeAssistant too?

Thanks a lot

Out of subject, just flash the ESP on it with ESPHome for example !! No need of dedicated component for it in HA !

HLK-SW16 already has a dedicated HA component, I thought it would be nice to the its little brothers HLK-SW04 & HLK-SW02 too.

I wouldn’t mind using ESPHome as you suggest … but it looks out of my skills. If it is to be my solution, can you please be more specific? Flash what with which firmware and how ?

Thanks

Author of the hlk-sw16 module here, I can probably add support for those if I have sample hardware or remote access to those modules.

edit: I pulled up some info on those and I think they may use the exact same protocol as the hlk-sw16 so if you want to buy them they will probably work as is.

Hi @jameshilliard
Very nice of you.
I go buy some of these and let you know.
Thanks for the answer.

hi james,

i have this board connected to my network and then ha config is attached

hassio side i have this config

hlk_sw16:
  relay1:
    host: 192.168.1.99
    port: 8080
    switches:
      0:
        name: relay1-0
      1:
        name: relay1-1
      2:
        name: relay1-2
      3:
        name: relay1-3
      4:
        name: relay1-4
      5:
        name: relay1-5
      6:
        name: relay1-6
      7:
        name: relay1-7
      8:
        name: relay1-8
      9:
        name: relay1-9
      a:
        name: relay1-a
      b:
        name: relay1-b
      c:
        name: relay1-c
      d:
        name: relay1-d
      e:
        name: relay1-e
      f:
        name: relay1-f

attached is the error i keep getting connected disconnected, serched every whre tried few things but its not connecting please suggest what might be going wrong or share your relay page setup so i can get it right

thanks in advace

Gagan

What happens if you try:

telnet 192.168.1.99 8080

hi,

Firstly thank you for quick reply sorry for late reply, when i telnet in to my host which is HLK-sw16 in this case it gives non stop gibberish letters attached in the video and screen shot below hard to make any sense

GIF-2019-11-27-18-30-08

thanks in advance

Strange, so it seems to be pushing data at least, is this a HLK-SW16?

Can you enable debug logging for this module so that it will log the raw packets?

logger:
  default: info
  logs:
    hlk_sw16: debug
    homeassistant.components.hlk_sw16: debug
    homeassistant.components.switch.hlk_sw16: debug

@Gagan_Kochar Hi, I am facing similar behavior with my HLK-SW16: disconnect/connect. While disconnected switch state appears as unavailable. Did you find a solution for it?

@jameshilliard
Here is what I have in logs

2020-01-19 06:16:42 INFO (MainThread) [hlk_sw16.protocol] disconnected because of close/abort.
2020-01-19 06:16:42 WARNING (MainThread) [homeassistant.components.hlk_sw16] HLK-SW16 relay1 disconnected
2020-01-19 06:16:42 DEBUG (MainThread) [hlk_sw16.protocol] Protocol disconnected...reconnecting
2020-01-19 06:16:42 WARNING (MainThread) [homeassistant.components.hlk_sw16] HLK-SW16 relay1 connected
2020-01-19 06:16:42 DEBUG (MainThread) [hlk_sw16.protocol] {'0': False, '1': False, '2': False, '3': False, '4': False, '5': False, '6': False, '7': False, '8': False, '9': False, 'a': False, 'b': False, 'c': False, 'd': False, 'e': False, 'f': False}

Is there anything else in your logs? I need to see the full logs, not just the last second, don’t cut off any lines.

So it appears there are multiple variants of the HLK-SW16 MCU firmware which have slightly different behavior. I should have a workaround soon to the timeout issue caused by the different behavior in some units.

This incompatibility should be fixed by this change.

Edit:
Just noting that my fix is now included in the latest home assistant release and was confirmed to fix the issue for @abaksa1.