tomaae / homeassistant-truenas

TrueNAS integration for Home Assistant
Apache License 2.0
183 stars 16 forks source link

[Feature] Update entity for new major version #122

Closed kotiverkko-reader closed 8 months ago

kotiverkko-reader commented 10 months ago

Describe the solution you'd like

Currently, the integration has one update entity which shows if a new minor version is available (e.g. 22.12.3.3 -> 22.12.4.2).

It would be great to have a second update entity which shows if a new major release is available (e.g. Bluefin -> Cobia, or 22.12.4.2 -> 23.10.0.1).

The current update entity does not show available major updates by default, because such updates only become available after the user first changes the update train to the latest major release in TrueNAS.

I'd prefer a separate update entity for major releases over incorporating major updates to the current entity because it would make it easier to send notifications from HA when a new major release is available.

tomaae commented 10 months ago

Is that even possible? Update entity reports status up update train as set in truenas.

kotiverkko-reader commented 10 months ago

I'm currently getting somewhat similar functionality via Ansible:

- name: Get available trains
  command: cli -m csv -c 'system update get_trains'
  changed_when: false
  register: trains

- name: List release trains if more than one is available
  debug:
    msg: "Available release trains: {{ trains.stdout | regex_findall('TrueNAS SCALE ([A-Za-z]+) \\[release\\]', '\\1') | flatten | unique }}"
  when: "trains.stdout | regex_findall('TrueNAS SCALE ([A-Za-z]+) \\[release\\]', '\\1') | flatten | unique | length > 1"
  changed_when: true

The first command fetches the list of available trains via TrueNAS CLI, and the second prints them out if there is more than one release train available (presumably indicating that an update is available). Here is the output when run against TrueNAS Scale 22.12.4.2:

image

Here is the output when run against TrueNAS Scale 23.10.0.1:

image

More specifically, the CLI command in the first task returns the following when run in TrueNAS Scale 22.12.4.2:

trains,current,selected
"{""TrueNAS-SCALE-Bluefin"": {""description"": ""TrueNAS SCALE Bluefin [release]""}, ""TrueNAS-SCALE-Cobia"": {""description"": ""TrueNAS SCALE Cobia [release]""}}",TrueNAS-SCALE-Bluefin,TrueNAS-SCALE-Bluefin

When run in TrueNAS-SCALE-23.10.0.1, it returns:

trains,current,selected
"{""TrueNAS-SCALE-Cobia"": {""description"": ""TrueNAS SCALE Cobia [release]""}}",TrueNAS-SCALE-Cobia,TrueNAS-SCALE-Cobia

The regex in second task finds the list of unique words between words "TrueNAS SCALE" and "[release]". In v22, this is ['Bluefin', 'Cobia']. In v23, it is ['Cobia'].

Maybe similar logic could be used in the Home Assistant integration as well?

tomaae commented 10 months ago

no, changing train is too invasive. disconnect or network hiccup could cause wrong train to be set up. that can have bad consequences.

kotiverkko-reader commented 10 months ago

I was suggesting an entity that checks if new trains are available, not one that can be used to actually change the train.

Such check can then be used to set up home assistant automation to notify user that new train is available and user should update to most recent version manually.

github-actions[bot] commented 8 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

github-actions[bot] commented 8 months ago

This issue was closed because it has been stalled for 5 days with no activity.