But now I want to expand this so it doesn’t control one media player but the currently playing media player(and even further if a cast group is playing I control the cast group instead of a single media player)
I’ve searched a bit but can’t find a way to template the media_player entity. Is there another way someone can think of?
ControllerX support HA groups of both lights and media players.
If your media player, like Sonos, provides a source list and current playing group as attributes, you can perhaps control the player/group of players in the same way as I’ve done with my Sonos speakers ?
Your could check the Sonos example in ControllerX documentation and see if same kind of setup could be used for your setup.
Direct templating in apps.yaml should be possible, but my knowledge on templating and appdeamon is quite limited. If direct templating can’t be done, you could do the templating on a HA sensor instead and use that as media player entity in apps.yaml
But it isn’t accepted. I’m now going to try to make a dynamic group with just one media_player in it the one I want to control(If you change the volume of a cast group the volume off all the speakers in the group change)
I’ve found a way to achieve what I want here’s what I did I case someone wants to do the same as me:
I’ve created a empty group:
current_media_player:
name: Current media player
Then I have setup a automation that triggers everytime when a media player changes state and then add the appropriate entity to the group(if a cast group is playing add the cast group and not the single entities) like this:
- alias: Current media player
initial_state: 'on'
trigger:
- platform: state
entity_id: media_player.all_speakers
- platform: state
entity_id: media_player.receiver_and_home
- platform: state
entity_id: media_player.living_room_home
- platform: state
entity_id: media_player.chromecast_audio
action:
- service: group.set
data_template:
object_id: current_media_player
entities: >
{% if is_state('media_player.all_speakers', 'playing') %}
media_player.all_speakers
{% elif is_state('media_player.receiver_and_home', 'playing') %}
media_player.receiver_and_home
{% elif is_state('media_player.living_room_home', 'playing') %}
media_player.living_room_home
{% elif is_state('media_player.chromecast_audio', 'playing') %}
media_player.chromecast_audio
{% else %}
media_player.living_room_home
{% endif %}
Then as media-player entity in ControllerX config use the group:
I think you found a nice solution to it. The solution I was about to propose involved a feature from AppDaemon, that allows you to activate and deactivate certain automation depending on the entities’ values (constrain callback). Here I leave how the config would look like with the solution I propose for 2 media players:
As you can see, the problem is that you need to repeat the configuration twice, this is why I still recommend your solution. Plus, I have not tested this out myself, but I think it should work.
Thank you for sharing the solution with us, I will be adding it into the example page, so people can reuse it if needed
Ha also nice solution. The only thing is that when a cast group is playing (and the group consist of 2 media players) you’ve got 3 media players playing and at that moment I want to control the group instead of the individual media players.
Glad you got your template up and running
I’ve only got Sonos speakers, so don’t really know how cast groups are integrated and controlled.
What if you (by choice) are playing different sources simultaniously on different devices ?
Or is that a non existing ‘control group’ issue in your case ?
is the media_player.all:speakers a group or a single device ?
In my case that would be difficult. My chromecast audio is connected to a receiver which has speakers in the living and the kitchen and my google home is also in the kitchen(open spaces all connected).
media_player.all_speakers is a single entity in hass but are actually 3 devices.
So if I cast to all speakers I have the 3 real speakers that show up as currently playing + the entity media_player.all_speakers. I can adjust the volume per speaker but I want to control the volume off all the speakers.
Of late my ikea sounds controller has gone very slow. I turn the dial and it can be up to 2 full seconds before the Sonos speaker Volume changes. From the HA front end changing the Sonos media player volume is almost instant.
Any ideas why controller X and the ikea sound controller would be so slow?
My guess is that I need a better zigbee network? My cr@ppy zigbee network is the issue.
Sad to hear you get some delays in your network. I have experienced the same before in my on network and it was due to have the devices far away from my network or interferences. So if I was you, I would be thinking on what you changed lately (removed some devices, moved them around, changed some setting on your wifi channels, etc), then you might figure out where the problem is coming.
As a final recommendation, I would tell you to restart your PI or computer, maybe it is suffering from some lack of space in memory and it might make your system to be slower.
I would also like to add that using E1744 with z2m is not the best choice, it works better with deconz due to the several layers that it needs to go through. I am working on something to make the z2m integration faster by operating directly with MQTT. You can read more about it in here
Hey, I’ve just tried to get ControllerX to work but somehow I’m unable to controle any lights.
Im using a conbee II and the standard deconz integration to homeassistant. The controller I’m trying to use is the E1810 from Ikea.
I installed ControllerX via HACS and my apps.yaml says the following:
Anyhow, your problem is not this. Did you install the AppDaemon addon or you have AppDaemon up and running already? If so, what are the AppDaemon logs?
Also, where did you place the configuration that you just showed me?
I managed to get an Ikea E1524 (what is the difference to a E1810?) remote to works as a remote for my Logitech Media Server without any problem.
Thank you very much for this great piece of software!
Is it possible to use also double press or long press actions on some buttons? The volume would stay the same, but e.g. the main button could do some extra thing when I do a long press.
I know I have to use CustomMediaPlayerController, but how to use a short press and a long press for the same button? As you can see I am using the deCONZ integration with a Conbee II stick.
If devices themselfes don’t deliver a group attribute, then perhaps you should consider making some different groups to match specific playing needs during the day.
But no need to make things more complicated, if you’re happy with a group solution where all active playing devices are added
Saw that you’ve made a feature request on Github regarding volume control of your group.
Annoying that not all media-players support volume_set calls
But it seems that you’re already done the neccesary coding and patched ControllerX to get a working solution
This controller does not support double. You can check the documentation to see the events that the controller fires. The only long press that does not work as expected is the center button since it fires the click event first and then the long click, but the rest you can use click and long press.
I did not understand exactly what is the use case you want to achieve, but I will leave you here a configuration so you understand how ControllerX works more deeply.
So the first config is the same one you sent, but it exclude the left and right arrow hold actions. Then I added two custom light controllers to toggle 2 lights with the events I excluded. I hope this helped you understand the potential of ControllerX and achieve what you want to do. Here for more information of custom controllers.
If you tell me exactly what is what you want to achieve, I will be able to help you with the configuration
Ok, that is not really good, because that would be the button I want to use. But left/right would be also a solution.
Yes, I didn’t wrote it clearly enough. Mainly I need a toggle for the speakers of the media player I want to control, as the don’t have to be switched on the whole day. So I need to control a switchable socket.
Yes, now the penny dropped. I think I understand now how to handle it.
Nice project,
I Enabled appdaemon in HACS. installed the controllerX automation in HACS, added the config for my IKEA E1743 remove to appdaemon/apps/apps.yaml file. But it doesn’t work and there are no logs on this matter. did i missen something?