This is a long shot ... but there may be someone who has done something like this before.
I have an ancient CD player which my wife likes to use. I'd like to be able to detect when it starts playing to trigger a flow I can configure to ensure the playback amp is powered on and the right input selected.
My Node-RED is running on a RPi4. I was wondering if the RPi4 could detect an audio stream if I got an analogue to digital USB soundcard, for example, but I've not been able to find anything online that looks relevant. Perhaps I haven't managed to ask the right question in my searches. Has anyone any suggestions for me to explore?
I think he is suggesting using an audio feed to do it... but then if the amp isn't switched on how would the Pi hear the audio in the first place... catch-22.
I would expect that if everything is setup well and you use pulseaudio (you might need to install it) that you would see at least an extra pulseaudio source (= audio input) when using command pactl list sources.
I suggest to check if the state changes when playing audio from your CD player. If so, you can poll this command every X minutes by a node-red execute node:
The cd player could be plugged in to a smart socket which can monitor power consumption.
My node-red knows when my coffee machine is on because the smart socket sends "current consumption" 1200W. Not sure how well it would recognise a low power device.
Thanks for taking the time to make these suggestions. I was initially thinking that USB audio devices are cheap and easily available, but the software side is perhaps tricky, if not impossible. Also there's a lot of CPU overhead listening all the time when all I'm after is an infrequent change of state that needs to be detected and reported promptly.
I had another idea which is to use the existing Node-RED RPi GPIO module, and find a way of making a physical connection. The chain might look like a device to detect that the optical signal on the CD's TOSLINK has gone live triggering a 12v (such as the Bobwire DAT1) connected to a micro relay, connected to the RPi GPIO. Since the DAT1 doesn't seem to be available in the UK, and it's expensive, then unless I find something else I may have to try and build my own. But this feels like a hardware hammer to crack this very small nut, rather than a software sledgehammer.
Can you hack the player?
If so, you could inline a sensor that detects power to an LED that comes on when the device is playing, or similar.
Or, if there is a physical play button that gets depressed, add contacts underneath it.
I admit that it is not clear to me which playback amp you want to power and which input you want to select. I am a bit puzzled about your actual Hardware setup.
It looks like I might have to hack something to make it work. But the only times I've used a soldering iron is to make up audio cables ... electronics is unchartered territory for me. Happy to have a go, but don't really know how to start.
I am using a TP=LINK KASA 115 to accurately detect between accurate 0mA and 10 mA to determine if an LED light is turned on in an overhead fan assembly.
I use this info to turn cooking lights on/off. 100% reliable1
Here is the output from the sensor. It might be able to detect the difference between the CD player being on/playing.
Thanks @RichdeCrep. That's great to hear that a smart socket like @jbudd first suggested does work to detect usage of such low power devices. I've checked the specs of the CD player and it looks like usage changes from "<3W in standby state" to "25W Typically use", so worth trying as a first step. The TP Link KP115 usually sells for around ÂŁ15, but seems to be sold out in the UK right now. I think I'll either wait or look for an alternative if it takes too long to restock. Thanks again.
There are lots of smart plugs available with energy monitoring.
Many of them turn your devices on and off via servers in China, which they dress up as a wonderful smart phone app.
The ones I use have been reflashed with Tasmota open source firmware. Unfortunately it's difficult to know which brands you can do that with; it relies on the PLC being an ESP8266 and an unfixed bug in the provided firmware.
So my new year's resolution is only ever to buy new ones from Athom since they have Tasmota out of the box https://www.athom.tech/blank-1/uk-plug
I am getting a Samsung GP-WOU019BBDWG zigbee smart plug which I hope will do the job, but I haven't got it yet, in fact I won't have it till Christmas. ÂŁ19.95 https://www.amazon.co.uk/gp/product/B07TK4CC42
There are cheaper ones but I decided it wasn't worth trying to save a few pounds.
Amazon sell zigbee smart plugs but AliExpress are cheaper (although they take longer to arrive)
I run all my zigbee devices through zigbee2mqtt and Node-RED so no apps required. I use the node-red-contrib-googlehome node to allow Google voice control but there are other nodes available (also for Alexa)
Thanks @Colin and @Buckskin - all really helpful suggestions. I think I can assemble the solution from this information, although it may take a little time to get the hardware. Thanks again.
Well since the socket it is being plugged into is only rated at 13A then that is definitely the case. I usually rate such devices at about half of what they say.