LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   need usb-controlled 110v switch that can be programatically operated from command line (https://www.linuxquestions.org/questions/linux-general-1/need-usb-controlled-110v-switch-that-can-be-programatically-operated-from-command-line-4175735845/)

davidwneill 04-09-2024 03:38 PM

need usb-controlled 110v switch that can be programatically operated from command line
 
My provider's modem loses communication, at least weekly.

I have had it replaced, and the problem persists. Could be a problem up-stream of the modem.

A power-cycle brings it back, but sometimes I'm away from home, and would like to log in... I can write the program to check for loss of communications, and send commands to the usb device on my system, but haven't found a controller that does that.

The normal operation would be for power to be on, and only be interrupted for a few seconds, if comms have been down for maybe an hour. Best would be a device that plugs in to normal power outlet, and provides 1 or possibly 2 switchable outlets.

Does anyone know of such an item? Cheap? ;^)

business_kid 04-10-2024 05:12 AM

I think you're in Catch-22. If you need to reset the isp's modem, you obviously have lost internet access. You said so yourself, because you can't reach your printer.So how can you communicate by wifi to the reset switch??

Even presuming the home setup is over-complicated technically, you don't need such a gimmick at all. Save or email whatever files you want to yourself, and print them when you go home. If your printer is that slow, buy new. If someone is there, let them reset your modem. And give your isp a rocket.

EDIT: It's a good rule to keep gimmicks away from mains. They're a very bad mix, and a fire risk. You could end up explaining to your home insurance company why they should pay up for a fire caused by your gimmick.

pan64 04-10-2024 05:36 AM

probably an ups helps. From the other hand an esp32 (or a SBC) and an IoT plug can do that.
like this: https://www.mindolife.com/product/smart-plug/ (I do not suggest it, just show as an example)

michaelk 04-10-2024 07:07 AM

Many smart plugs require the internet or some sort of cloud environment. I found this relay box but you need something like a Pi to control it. A Pi Zero W is only around $15 US but you need the power supply, memory card etc to make it functional which adds up.

https://www.amazon.com/Iot-Relay-Enc.../dp/B00WV7GMA2

There are ethernet and USB relays you can wire up if you want a DIY project.

davidwneill 04-10-2024 07:37 AM

I found this:
https://pwrusb.com/products/powerusb-basic
which fits the bill, except for cheap...

I guess I wasn't clear enough.. what I want is for the system to
detect loss of internet access (easy enough, ping works), and then,
after a few consecutive failures, to issue the command to power-cycle
the provider's modem.

If it can also power-cycle the wifi router (separate hardware), then
that's ok, but the controlling system is hard-wired to the router,
which is hardwired to the provider's modem.. no wifi involved.

pan64 04-10-2024 07:49 AM

Quote:

Originally Posted by davidwneill (Post 6495152)
I found this:
https://pwrusb.com/products/powerusb-basic
which fits the bill, except for cheap...

I guess I wasn't clear enough.. what I want is for the system to
detect loss of internet access (easy enough, ping works), and then,
after a few consecutive failures, to issue the command to power-cycle
the provider's modem.

If it can also power-cycle the wifi router (separate hardware), then
that's ok, but the controlling system is hard-wired to the router,
which is hardwired to the provider's modem.. no wifi involved.

Yes, I think it was ok. You can check it with any esp32 based device or SBC (running on batteries) or similar (like a raspberry pi) and use a "smart" plug to reset the modem. You can use an old laptop for this.

But based on your last post I don't really know what is missing for you.

allend 04-10-2024 08:08 AM

When I have experienced this, I have found that I can still access my modem from a web browser and navigate to a reboot option. I have never tried to do this programmatically, but it may be an approach to consider.

michaelk 04-10-2024 10:28 AM

Quote:

Q2. The software is not working my Linux platform. How do I get it working

A: Since there are many variants of Linux, our software may not be compatible on few versions. We have limited support for Linux. We have shared the source code for shared object (.so) file under www.pwrusb.com/linux/so_source/. You can try to compile it and build the .so file in your environment and your version of linux/ubuntu
It looks good and most likely building from source will work but.

TB0ne 04-10-2024 10:49 AM

Quote:

Originally Posted by allend (Post 6495161)
When I have experienced this, I have found that I can still access my modem from a web browser and navigate to a reboot option. I have never tried to do this programmatically, but it may be an approach to consider.

Agreed....I'd look at what SNMP options it has, since you may be able to use snmpset to issue a reboot command.

That said, I'd probably first consider telling your provider that the modem you have is junk, and ask for a new one. They often upgrade hardware but don't say anything to older customers since it's cheaper to leave the old stuff there until someone complains.

pan64 04-10-2024 10:57 AM

Quote:

Originally Posted by TB0ne (Post 6495177)
They often upgrade hardware but don't say anything to older customers since it's cheaper to leave the old stuff there until someone complains.

Yes, probably the cheapest solution is to replace the hardware.

michaelk 04-10-2024 11:23 AM

Not necessarily bad hardware. If you have cable internet then your ISP should be able to read the signal level at the MODEM (most other services should be able to as well) and see if it is marginal. Internet needs more signal strength then TV. At one time I had a bad signal but the ISP reading supposedly was acceptable. The true reading with a meter at my house proved it was not. Bad wiring, connector corrosion (my problem), loose connectors or even a bad splitter can cause problems. You can have similar problems with other types of Internet service as well.

jefro 04-16-2024 03:12 PM

Get a 24 hour timer and let it reboot every day? Some electronic models can be set to a minute. Mechanical might be 15 minutes minimum.

michaelk 04-16-2024 07:46 PM

The mechanical ones are typically 30 minute intervals and digital by the minute. That would be the simplest although depending when the outage happens it could be after the reset.

I am not suggesting this particular device but there are several USB relays that appear as virtual serial ports. It would not be difficult to write a program to interface with these devices. Be sure if you choose one of these devices it exceeds the current required by your MODEM/router. It would also be a bit of a DIY project to wire up a cable.

https://www.amazon.com/Module-Intell...8235f6f86353c9

jefro 04-16-2024 08:31 PM

A universal digital timer might cost under $10.

I have some KASA devices that are supposed to work even if it doesn't have wifi. So you can get them and use them on a schedule or if wifi you can control remotely.


All times are GMT -5. The time now is 02:57 PM.