WolfwithSword / Bambu-HomeAssistant-Flows

A collection of HomeAssistant Dashboards and NodeRed Flows with a configurator to connect a BambuLabs printer to HomeAssistant through MQTT - based off of my Gists
32 stars 3 forks source link

[Idea] Button card if any update to the cards is available #8

Open informagico opened 2 weeks ago

informagico commented 2 weeks ago

This is just an idea/proof of concept and didn't wanted to add a PR 😄 It would be interesting to have something on the dashboard that let you know if there are any updates available for the cards.

I imagined something like this.

Add a sensor that fetches latest release from GitHub (I know, there are also blueprints/etc..)

command_line:
  - sensor:
      command: "curl https://api.github.com/repos/WolfwithSword/Bambu-HomeAssistant-Flows/releases/latest"
      name: wws_ha_bambulab_cards_version
      scan_interval: 3600
      value_template: "{{ value_json.tag_name }}"

Add a conditional card on the dashboard that shows a button if any update is available

type: conditional
conditions:
  - condition: value
    entity: sensor.wws_ha_bambulab_cards_version
    state_not: unavailable
  - condition: value
    entity: sensor.wws_ha_bambulab_cards_version
    state_not: undefined
  - condition: value
    entity: sensor.wws_ha_bambulab_cards_version
    state_not: {CURRENT_VERSION}
card:
  type: custom:button-card
  name: WolfwithSword's Cards Update Available
  show_icon: true
  icon: mdi:download
  tap_action:
    action: url
    url_path: https://www.wolfwithsword.com/bambulab-home-assistant-dashboard/
  layout: icon_name
  styles:
    grid:
      - grid-template-columns: 20% 1fr
    icon:
      - color: '#f79300'
    name:
      - text-wrap: balance
      - font-weight: bold

Example of update available: image

Once clicked it redirects to your website.

WolfwithSword commented 2 weeks ago

I did recently put in an update checker into my nodered flows to add a latest-version sensor for the basic and advanced flows. It used a versions.json file that I also include the dashboard yamls in, but currently it is unused.

https://raw.githubusercontent.com/WolfwithSword/Bambu-HomeAssistant-Flows/main/files/nodered/resources/versions.json

would be much more reliable than getting latest version, as I do not update the cards with every release (since everything is in the same repository).

Though it's also a bit tough because not every release updates all the cards too (printer yaml(s) for each printer, details yaml, fan/temp control yaml, each ams or external spool yaml etc), and atm I only bundle them as one version.

I like the idea, will play around with it a bit.

informagico commented 2 weeks ago

Oh, that's cool! Yes, the fact that everything is in the same repository makes it difficult to understand (from the user POV) if it is actually needed to update but still, could be a nice touch to have something that says "hey, watch out for an updated version of the dashboard!" 😃

WolfwithSword commented 2 weeks ago

Yeah since this started out as just a collection of gists, when I moved everything over to a repo I still had mainly just the nodered support, so having it all in one place was fine (since also then, the dashboard yamls rarely ever updated).

It's why for the most part, I always outline in the release notes on github what actually changes in each release, and update the guides to reflect.