I’m looking to turn on a socket when the music is played/resumed and to turn it off after it’s stopped/paused. The pause/resume sequence is happening over the LMS protocol, so it doesn’t (always) go through HA.
I could use PiCorePlayer, which I think supports my scenario, but it didn’t work so well for me and instead using an old Android phone with SqueezePlayer, which is a lot more reliable.
The player is integrated into HA using the LMS integration and it detects whether it’s playing or not. I could use that for an automation, just wondering if anyone else wanted to achieve something similar and how they did it.
Hello I use LMS and PiCorePlayer on RaspberryPi. Slimserver Forums have details on how to use the pins and you will see in PCP that there are options for setting certain pins high and low on start and stop. I have it on my project list to work out how to send a message to HA so I can turn my smart plugs on and off
I did manage to create an automation just with HA. Obviously, it reacts almost instantly when controlled from HA and it takes about 2-5 seconds when pause/resume is controlled from another interface (such as LMS web).
alias: Turn off socket when music stops
description: ""
trigger:
- platform: state
entity_id:
- media_player.squeezeplayer_2
to:
- paused
- "off"
- idle
for:
hours: 0
minutes: 0
seconds: 5
condition: []
action:
- type: turn_off
device_id: 959b4a113b01b75594d781d37ee9f8a8
entity_id: switch.tasmota_1
domain: switch
mode: single
alias: Turn on socket when playing music
description: ""
trigger:
- platform: state
entity_id:
- media_player.squeezeplayer_2
to: playing
condition: []
action:
- type: turn_on
device_id: 959b4a113b01b75594d781d37ee9f8a8
entity_id: switch.tasmota_1
domain: switch
mode: single
One can use the visual editor to create the automation, which I find a lot faster to use, then go into YAML mode and add more entity_id[s] and trigger states:
The reason for this automation is that the ‘automatic’ subwoofer doesn’t really turn itself off when no signal is detected and draws about 15W when idle.
@ha-username thank you so much. You have just helped me with my problem. I took a look at the attributes and state of my media players which are showing up from the LMS integration and realised that your automation is perfect. Can I play with how well this works and then take a look at your original question
If I use the LMS integration my nodes show up but there is a lag.
However, if use the DLNA Digital Media Renderer and configure a player through that integration, the state of the player shows up instantly. No lag. The LMS integration is still there for using media cards etc.
My amps are now turning on and off like a dream. Happy days.