Mains powered USB hub?

So I have an odd issue happen…sometimes…randomly.

HA will lose knowledge that it has my Zwave/Zigbee stick plugged into the USB port. I’ve tried different port, different extensions. Those dont seem to matter.

I’ve tried killing power to HA (Blue device), that doesnt work.

Only thing that works is unplugging the stick and plugging it back in. Which is great when I am home and it happens. But when I am not home, I have no way to get my Zwave/Zigbee back up.

So my thought was if I had a mains powered USB hub, then I could connect it to a WIFI outlet. If I see HA has forgot it has a stick plugged into it, I could kill power to the wifi outlet and then restore it.

I use these flashed with ESPHome to turn on and off usb devices

£3.40 | Sinilink APP WIFI-USB mobile phone remote controller 3.5-20V 5A 100W mobile phone APP smart home XY-WFUSB For arduino
https://a.aliexpress.com/_EJUXYEL

1 Like

Can you provide more info on how to flash these? I dabble some in ESPhome, but not much.

Sure, I connected a serial adapter to the pins on the board as shown here and flashed. The pins are there also and a good video link. It shows Tasmota but I just flashed an Esphome bin instead. My Esphome config for switching an LED keyboard mat is below.

esphome:
  name: keyboard-mat
  comment: SINILINK USB

esp8266:
  board: esp8285
  restore_from_flash: true

wifi:
  networks:
    - ssid: network
      password: !secret wifi_password
  ap:
    ssid: ESP Keyboard Mat
    password: !secret wifi_password
  fast_connect: true

captive_portal:
logger:
api:
ota:

binary_sensor:
  - platform: gpio
    pin: GPIO4
    name: Keyboard Mat Button

  - platform: status
    name: Keyboard Mat ESP Status

output:
  - platform: gpio
    id: mosfet
    pin: GPIO05

light:
  - platform: binary
    name: Keyboard Mat Light
    output: mosfet

sensor:
  - platform: wifi_signal
    name: Keyboard Mat Light WiFi Signal
    update_interval: 60s

text_sensor:
  - platform: wifi_info
    ip_address:
      name: Keyboard Mat Light IP
    ssid:
      name: Keyboard Mat Light SSID
    mac_address:
      name: Keyboard Mat Light MAC

button:
  - platform: restart
    name: Keyboard Mat Light Restart
1 Like

Thank you. Just ordered all the supplies I should need! Now have to wait…

What are you using to flash the esphome bin and where did you get the bin?

Used the code above in Esphome and compile to a bin and download. Then flashed with ESPHome flasher.

You could now flash straight from the Esphome dashboard

Ahhh ok, I didnt know that was considered the bin. Thanks.

Yes sorry I should have said .bin file

Okay but now I actually have a another question lol. So that code you shared is that just the bin or is that the YAML too?

So my only experience with ESP home was I purchased a ESP board and connected a time of flight sensor to it and I found yaml template that I just had to slightly modify and then I wrote it to the chip.

With this project is that also all I would be doing with the code you shared? Or do I need to flash the chip with the code you provided and then also something else? I just think I’m not grasping something right now

You need to create a new device in the esphome dashboard, paste in the yaml code above, edit it to suit you (names etc) and flash using esphome to the Sinilink USB module with usb cable from the machine to the Sinilink USB module
If you’re not sure about flashing with esphome, have a look at the esphome docs:

Also, watch this vid, it looks at the Sinilink

Thanks for the recommendation. I’ve ordered and received one of these, flashed it with ESPHome and have freed up a mains smart plug that was running my kitchen tablet USB charger, as I now use this device inline. Bonkers cheap for what it is.

@Troon are you saying you ordered a sinilink AFTER i created this post? If so, where the heck did you order from that you already got it??? Soonest I could find was Jan 31.

Yes. I ordered it from AliExpress on 10 Jan: they were suggesting it might be early Feb before it turned up, but Andy my friendly local Evri delivery man popped it through my door (UK) on 18 Jan.

I was surprised too: must have been airfreighted.

@Holdestmade

I got the sinilink and flashed it with your code. Only changing the wifi for now until I get an understanding on what the rest of the code does.

When I go into HA and look at the device, 'Keyboard Mat Light" under controls turns off and on the usb (i see a red light on the unit turn off and on). Great!

But what is the “Keyboard Mat Button” sensor for? Its always showing on.

Also, can I change it from a light to a switch?

I tried editing the code and replacing light with switch but then I get an error that switch.binary doesnt exist

The Sensor is the button on the side of the USB, it’s not that reliable though for some reason.

TO have a switch instead, delete the output and light sections and add:

switch:
  - platform: gpio
    pin: GPIO05
    name: Switch
1 Like

Thanks for all your help @Holdestmade. Last ?, whats the restart thing do? Do you use it?

I have them in all my ESPHome configs, sometimes need to do a restart when they get stuck on a far away access point