Hi,
I’m quite new to home assistant and trying to control my squeezebox media servers with my KNX wall switches. The goals I want to achieve is as follows:
- Use KNX switches to change volume ( I think I knew how to achieve this, but I haven’t tried so far)
- Show current playlist on the screen of the wall switch (Here I’m currently stuck)
- Use KNX Wall switch, to iterate through available playlists (I did’t try this so far, because of 2.)
Thats my current state:
I created a small python script, which I can execute by hand with the UI. The Script queries the last loaded playlist from the squeezebox player. This seems to work so far.
After that a new state is created in the entity of the squeezebox player to store the playlist information. Here I’m not sure if this does work. Here is the python script.
entity_id = 'media_player.kitchen'
hass.services.call("squeezebox", "call_query", { "entity_id": entity_id, "command": "playlist", "parameters": ['playlistsinfo']})
result = hass.states.get(entity_id).attributes['query_result']
if 'id' in result:
inputStateObject = hass.states.get(entity_id)
if inputStateObject :
inputState = inputStateObject.state
inputAttributesObject = inputStateObject.attributes.copy()
inputAttributesObject['current_playlist'] = result
hass.states.set(entity_id, inputState, inputAttributesObject)
logger.info("attributes %s", inputAttributesObject)
In addition I configured the KNX switch, so that I can send text to it, which it does display. As a value for the text, I used the newly created attribute like follows:
knx:
expose:
- type: string
address: "5/2/0"
entity_id: "media_player.kitchen"
attribute: media_player.kitchen.current_playlist.name
I don’t get an error, but the switch is not displaying the playlist. As a simplification I removed the “attribute” line to just display the current state on the switch. Since then it does display “playing”. Because of that I assume, that displaying text does work in general.
Can you give me a hint, what I’m doing wrong?
Jeremia