Turn on smartplug amplifier with REST API

supersix

New member
Joined
May 17, 2024
Messages
3
My amplifier is connected to a Shelly Plug smartplug.
I would like to control its power state automatically, according to Wiim mini playing state, just like a "virtual 12V trigger".
Powering on a Shelly Plug is easy: http://192.168.xxx.xxx/relay/0?turn=on
Powering it off is easy too: http://192.168.xxx.xxx/relay/0?turn=off
Authentication with challenge-response is available too.

Thanks

References:
 
Upvote 1
Many amps have their own 12v triggers, could you not use the amp's trigger to connect to the WiiM?

Another option is to connect both the amp and the WiiM to the shelly plug using an adaptor.
 
Many amps have their own 12v triggers, could you not use the amp's trigger to connect to the WiiM?
It's a vintage amplifier, so no 12v trigger.
Another option is to connect both the amp and the WiiM to the shelly plug using an adaptor.
That requires to operate the Shelly app, then the music app, then remember to use the shelly app again to power off the amplifier.
Possible, but definitely more inconvenient than virtual trigger managed by Wiim Mini.
 
If you are running a script to control your Shelly Plug could you use the same device running the script to continuously query the WiiM state and if it is on turn on the Shelly Plug?


In your setup, since you can control you vintage amplifier with a smart plug, you should be able to replace the smart plug with an Audiophonics 12V trigger.


If your amplifier has a captive power cord you'll need to purchase two power adapter cords to complete the setup.
 
+1 for this API.

Just using the trigger to control the amp won't work for me as I need to turn on the amplifier for other uses as well (e.g. watching TV). I can't just monitor the getPlayerStatus API as it does not change when the WiiM Pro is used as a slave in a multiroom music setup, and just reports "stop" all the time.

The standby light, on the other hand, does change depending on whether the player is actively rendering music or has been idle for some time. The trigger signal is the same. If I could determine the status of either of these using the API I could use HomeAssistant to turn my amplifier on or off reliably. Currently the only workaround for this is to add a second device that HomeAssistant can use to monitor the 12v trigger, which seems crazy since the player has a REST API and could report the status itself.
 
This is a great idea IMHO.

In addition to a software-defined 'trigger' function to act on a smart plug, you could also just HTTP POST the device state to a custom destination and have the receiving script act as a middleman to decide what action to take. E.g.
* power on an outlet when playback starts
* power it off again when the WiiM itself goes into standby/sleep
* display the current state & track name on some custom UI anywhere...
 
it’s not super complicated thing to do. You gonna need a “server” raspberry pi for example and a simple python/shell script that pulls both API’s.

Speaking of the script, I think Chat GPT is able to come up with something half-decent.

I run something similar “connecting” my WiiM pro plus with AWTRIX clock to display the volume bar.

DM me for Python script example if you’re interested.
 
You mean polling the WiiM API all day long 24/7? Not really efficient + that means any action you want based on the state will always come with a delay between the polls. If the amp is only powered up 45 seconds after the wiim starts playing, other family members will be annoyed.
 
You mean polling the WiiM API all day long 24/7? Not really efficient + that means any action you want based on the state will always come with a delay between the polls. If the amp is only powered up 45 seconds after the wiim starts playing, other family members will be annoyed.
theoretically it might be a way to use the “standby” status of wiim, just the way 12v trigger works.

There is nothing wrong pulling api 24/7.. push notifications, MQTT and a bunch of other protocols essentially work this way - constantly checking server if there is new data. i pull my wiim api twice a second with no issue.
 
it would be a hell of lot easier if wiim supported mqtt. Then you’d be able to route everything through the Home Assistant without messing with python. instead WiiM team decided to implement proprietary Control4 😭
 
I might be wrong, but afaik push messaging uses a TCP connection that stays open all the time. The client just keeps listening until the server feels like sending a message. No 3-way handshake twice a second etc.

But mqtt would have been nice indeed.
 
you’re not wrong @pvdputte but here we are dealing with one server and a couple of clients in the same network situation. the overhead will be negligible
 
Back
Top