house-of-abbey / GarminHomeAssistant

Garmin application to provide a dashboard to control your Home Assistant
https://community.home-assistant.io/t/home-assistant-app-for-garmin/637348
MIT License
70 stars 12 forks source link

Playing media player toggle rendered as "off" #130

Closed jose1711 closed 4 months ago

jose1711 commented 4 months ago

My menu item goes like this:

    {
     "entity": "media_player.ht_a5000",
     "name": "🔈 Soundbar",
     "type": "toggle"
    }

The issue is that during the playback the state is "playing" (not "on"). I believe the application is only checking on/off values in HomeAssistantToggleMenuItem.mc. Would it be possible to handle this more like HA does? Thank you.

philipabbey commented 4 months ago

Thank you for your interest. I will remove the bug label since this is not a bug in the slightest!

Please try using a "Template" menu item for things that are not as simple as on-off like lights and switches. You should be able to decode the states as you would prefer.

I'll close this issue in 48 hours if there are no further replies.

jose1711 commented 4 months ago

Thank you. Does that mean that toggle item only can be used with states objects that return on or off?

philipabbey commented 4 months ago

Yes. The API call must return "on" or "off" see these two points in the code:

The set state API call must use turn_on and turn_off:

Think of a toggle as just a specialised template for things that are obviously on-off, e.g. covers can be ambiguous here (open/closed - which is green for on?) Its just the template requires a little more work, but the user can get what they precisely need.

jose1711 commented 4 months ago

Thank you for the explanation. To be able to "emulate" a standard toggle using template, I am missing an option to set an icon. Template icon - unlike toggle - seems to only support static icon. Is there a chance to change this?

philipabbey commented 4 months ago

Garmin Connect IQ does not support the provision of any icons in menu items. The toggle is a special case. I suggest you choose unicode characters to put in a conditional Jinga statement in your template definition.

philipabbey commented 4 months ago

Closing as the issue has gone stale.