Nerwyn / android-tv-card

Universal Customizable TV Remote Card, with HA actions, super configurable touchpad, slider, haptics, and keyboard

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Multiple instances of the card in same view not working

LucaLa2001 opened this issue · comments

Checklist:

  • I updated to the latest version available
  • I cleared the cache of my browser

Release with the issue:
3.4.0

Last working release (if known):

Browser and Operating System:

Chrome on Windows 11, but the same issue occurs also on companion app on android

Description of problem:

When in the same view there are multiple instances of android-tv-card with different media players all volume's sliders of all card in the view control the volume of the entity defined in the last card.

Javascript errors shown in the web inspector (if applicable):
In web inspector shows no errors

Your Full Remote Config

Additional information:
I have a tv and a speaker, so I'm using one instance of the card for the tv and another one for the speaker with only the volume slider. I noticed this issue with the volume, but maybe it occurs also with other commands, like the touchapd, unfortunately I can't verify this at the moment.

That almost sounds like a bug with Home Assistant itself, I'm not sure how that is even possible.

You didn't post your remote configs. I'll need them to evaluate what's going on. I'm not seeing this bug on my remote test view.

Sorry I forgot, here is the code of my view

  - title: test
    path: test
    badges: []
    cards:
      - type: custom:android-tv-card
        slider_id: media_player.luca
        rows:
          - - volume_slider
      - type: custom:android-tv-card
        remote_id: remote.tv_luca
        slider_id: media_player.tv_luca
        keyboard_id: media_player.tv_luca_adb
        rows:
          - - volume_mute
            - volume_down
            - volume_up
          - - touchpad
          - - back
            - play_pause
            - home
            - keyboard

I've done some more testing, maybe it is not useful, but I discovered that if the card of the speaker is placed before the card of tv I can change tv's volume but when i try to set speaker's volume i get the error "Entity media_player.tv_luca does not support this service" (my tv support only rising or lowering the volume, not setting a specific value), while if the speaker's card is placed after the tv's one then everything is working fine.

Well this is really weird, I can recreate it. I do not understand how this is possible if these are two different cards. Home Assistant should be isolating them. This has to be a bug in Home Assistant, right? I don't even know if I can fix this.

I am seeing this error when the slider is on top but not on bottom and I remove slider_id from the second remote.

{
    "code": "invalid_format",
    "message": "not a valid value for dictionary value @ data['entity_id']"
}

Which means that the slider ID is not correctly auto-populating the default key for slider. What I think is happening is that one global defaultKeys object is being used for all remotes on a page, but since I was adding the slider ID to this default keys service data it was getting overwritten by subsequent remotes with slider_id. I'll work on a possible fix later today.

@LucaLa2001 can you try the latest beta? I think the issue should be fixed. It was some not great slider ID setting logic I had which was overwriting the default slider action for all cards on a page. I've also ported over my slider tooltip code from my other project and plan to work on some more fixes for both simultaneously.

The issue seems to be resolved, but now when I try to chenge player's volume from the slider the volume is always set to 50% and no sound comes out of the speaker and when I set player's volume with a service call the slider is not updated.

That doesn't sound good. So it's not working when you set it using the service call tool either?

Sorry for the confusion, I can change player’s volume with a service call or from the default Home Assistant UI, but when I change it the slider is not updated to represent the new value, in addition when I try to change volume from the slider the speaker’s volume seems to go to zero (no sound coming out) and the volume in default more info dialog is reported to be 50% (while the slider reports the volume that I try to set with it).

Do you know if it's 50% or 0.50? By default the slider in this card has a range from 0-1 with step size 0.01. You may have to set slider_range to min and max volume of the media players.

Wait no I think I broke something

There was a line of code I forgot to save before committing. Try the latest beta now, it should work.

Now it's working thank you. I noticed that the slider does not update when the volume is changed with a service call or from another device, is it the intended behaviour?

I think that's a visual bug with the input range element itself, which I can't fix recently learned how to fix and should implement in the next minor/patch version. If you don't touch the slider but update it from another device or service call, it does update. But once you touch it it doesn't visually update despite it's value changes.

I've done a massive refactor of the slider code in the latest beta. I'm probably going to work on adding parts of #25 into this release too since I'm on a roll unifying the sliders between my two projects.

Since the slider not updating is not a bug related with this project I closed this bug.
@Nerwyn thank you very much for all the work and the time dedicated to the community.

Gonna keep this open until I actually release the changes.

Fixed in 3.5.0