addyire / ha-menu

An app to interact with Home Assistant in the macOS menu bar.
MIT License
236 stars 1 forks source link

Icon Changes based on state #9

Closed trackermb closed 1 year ago

trackermb commented 1 year ago

Hi was wondering is there anyway to change the icon based on the state of an entity.

eg when state on "icon": "office-on.png" and when state is off office-off.png.

Have tried a couple of way but can seem to get any to work.

Here's and example of one that i tried but didn't work

    {
      "type": "label",
      "labelTemplate": "{% if is_state('light.office', 'on') %}Office light is on{% else %}Office light is off{% endif %}",
      "icon": "{% if is_state('light.office', 'on') %}toggle-on.png{% else %}toggle-off.png{% endif %}"
    },

Thanks in advance

addyire commented 1 year ago

Change "icon" to "iconTemplate"

trackermb commented 1 year ago

Hi thanks for your fast response. That worked a treat. Just wondering do you have any plans to edit the refresh down as low as 1 second as when using icons to identify if something is on a minute delay on refresh is a bit long.

Thanks again

addyire commented 1 year ago

The icons should refresh when the entire menu bar refreshes. The refresh rate you enter in the preferences is in minutes so just put in .01666 to refresh every second. Keep in mind this will consume much more power.

trackermb commented 1 year ago

Hi Thanks for that tip but I have changed the to as below in the settings.json but it still is only refreshing every minute. Seems like it can't accept anything less than 1 mins. Can you think of a work around as im guessing it would be a lot of work to change mins to seconds

refreshInterval : .01666