deConz Addon - deConz Firmware integration sensor

I am using the official HA deConz addon.

Is there a way to make an automation which notifies when the deConz firmware as a new update?
Or maybe incorporate this functionality into the addon, so an notification group can be added in the addon config?

1 Like

Hello,
Do you find some information about that ?
The firmware version is include in the integration page, but I don’t know how I get it…

Nope. :pensive:

Did anybody find a component to achieve update notifications?

Also interested in this :heavy_check_mark:

Use this:

  - platform: github
    access_token: !secret GitHub_Token
    repositories:
      - path: 'dresden-elektronik/deconz-rest-plugin'
        name: Zigbee Conbee1
    scan_interval: 86400

And then in your automation use:

- alias: 'Zigbee Conbee1 new firmaware notification'
  trigger:
    - platform: template
      value_template: >-
        {% set version = state_attr('sensor.zigbee_conbee1', 'latest_release_tag') %}
        {% if "beta" not in version %}
          true
        {% endif %}
  action:
    - wait_template: >-
        {% if "11:00" < now().strftime("%H:%M") < "21:00" %}
          true
        {% endif %}
    - service: notify.me
      data:
        title: HA - Information
        message: New firmare for Zigbee Conbee {{state_attr('sensor.zigbee_conbee1', 'latest_release_tag')}} is available

Two questions:

  1. Is there an advanced version which directly puts the information “update available” in a sensor which can also be used in a lovelace card?
  2. How to get the current firmware? If I read it correct existing yaml “just” tells “Well there is an update” but there´s no check related to the existing firmware on the hardware, so I could use this yaml without any deCONZ device. It might be “okay” but is only “half the way gone”, right?

I think I could achieve #1 and provide an updated yaml if someone points me in the right direction for #2 - how to get current used firmware version.

This was the poor man’s solution, does not actually monitor the installed firmware vs. latest release, but the latest Github version number.
image

For uptdate sensor try:

sensor:      # or binary_sensor {{ version }} or {{ true }}
  - platform: template
    sensors:
      conbee1_fw_updater:
        value_template: >-
            {% set version = state_attr('sensor.zigbee_conbee1', 'latest_release_tag') %}
            {% if "beta" not  in version %}
              {{ version }} 
            {% endif %}
            

I know I can see the current version in the Addon Phoscon web app. But I want to have it as sensor so I can use it in my Lovelace UI (updates dashboard) like I do with all important updates:

OK, this is what I currently use:

In a package:

# Firmware-Update-Sensor für deCONZ-Firmware (ZigBee-Gateway)
# Quelle: https://community.home-assistant.io/t/deconz-addon-deconz-firmware-update-notification/118915/6
  - platform: github
    access_token: !secret GitHub_token_deCONZ
    repositories:
      - path: 'dresden-elektronik/deconz-rest-plugin'
        name: "deCONZ Firmware"
    scan_interval: 86400
  - platform: template
    sensors:
      zigbee_firmware_latest:
        friendly_name: "deCONZ Firmware latest"
        value_template: >-
          {% set version = state_attr('sensor.deconz_firmware', 'latest_release_tag') %}
          {% if "beta" not in version %}
          # Alternativ zu nächster Zeile "{{ version }}" möglich um Versionsnummer (Attribut aus GitHub-Quell-Sensor) anstelle binärem Zustand zu setzen
          # {{ version }}
            true
          {% else %}
            false
          {% endif %}

In addition I use that sensor in a lovelace card entry amongst others…

  - type: conditional
    conditions:
      - entity: sensor.zigbee_firmware_latest
        state: 'true'
    card:
      type: entities
      entities:
        - type: 'custom:multiple-entity-row'
          entity: sensor.zigbee_firmware_latest
          name: 'deCONZ Firmware'
          icon: 'mdi:update'
          toggle: false
          state_color: false
          show_state: true
          secondary_info: ''
          entities:
            - entity: sensor.deconz_firmware
              name: Latest
              attribute: latest_release_tag
          state_header: Update?
          column: false

(uses a custom lovelace card from HACS)

…as well as in an automation for notification (grouped with other device firmware triggers, removed in the following code snippet):

alias: Notify_Devices_Firmware-Update(s)
description: ''
trigger:
  - platform: state
    entity_id: sensor.zigbee_firmware_latest
    from: 'false'
    to: 'true'
condition: []
action:
  - service: notify.me
    data:
      title: "Firmware-Updates available "
      message: >-
        ℹ Info: Firmware-Update(s) available. See lovelace update
        section or settings for details.
      data:
        subtitle: Devices
        push:
          thread-id: devices-notification-group
mode: single

So current status with this is:

  1. No idea if it actually works, cause sensor value only changes (and automation triggers) when there´s a new latest version release which is not beta
  2. It does not (yet) provide a separate sensor or attribute for the current firmware installed
  3. It does not (yet) provide an automation which only triggers if latest_version (information available) is newer than installed_version (cause we don´t know what installed_version is, see #2)

If anyone with better HA/yaml skills can figure out how to…

  • get #2 working and
  • in addition how to go through the github release information and explicitly use the latest non-beta version instead of only looking at the latest version

…I´m quite confident the remaining part should be quite easy to finally make a “rich man” version :smiley:

The integration for Deconz has this in HA:
image

Is there a way to pick up the firmware version from the integration and make a template sensor for this?
-If so, monitoring Github and compare to the installed integration would then be possible.

@CentralCommand Any wizardry from you would be appreciated.

1 Like

I don’t use the deconz integration so I have limited exploration capabilities here unfortunately. Also sadly the fact that it is shown in that UI doesn’t mean there’s any way to get to it in a template. To my knowledge there is no way to get to a list of devices or information on a particular device in a template. HA code has access to it but it isn’t made available to templates. I would absolutely love to be corrected on this but have not found or seen a way to do it.

However I poked around in the deconz integration code a bit and it doesn’t look like the firmware version is actually stored in the config entry. Looks like the integration makes the config entry here and this is all it appears to store for a bridge:

{
  CONF_HOST: self.deconz_config[CONF_HOST],
  CONF_PORT: self.deconz_config[CONF_PORT],
  CONF_API_KEY: self.deconz_config[CONF_API_KEY],
}

Should be easy enough to confirm this if one of you pokes around in .storage to find the entry created for your bridge. Think it should either be under core.config_entries or core.device_registry. I can’t test this myself since I don’t use the deconz integration. It makes sense that HA wouldn’t store this information though since HA wants to show up to date information and the firmware is updated outside of HA.

The python library that the deconz integration relies on is here. Poking around in here it looks like there’s a REST API the integration relies on. The code unfortunately has a broken link to the REST docs (http://dresden-elektronik.github.io/deconz-rest-doc/config/) but I believe the actual doc is here: https://dresden-elektronik.github.io/deconz-rest-doc/getting_started/. And within that we have an API that looks like it gives you the firmware version in the response - Get configuration. You’ll have to go through getting started to find the URL of your API but once you do you should be able to set up a RESTful sensor that contains the version of your firmware.

There’s even an API for Updating the firmware once you know there’s a new version available if you wanted to provide an “update” action in your notification or an “update” button in your dashboard.

That’s probably as far as I can go with research though without one of these devices. Hopefully one of you all can take it from there and get it working.

2 Likes

Thanks for your replying and your educational insight.
Unfortunately the files “core.config_entries” and “core.device_registry” did not contain firmware version data.

This is over my know-how-level, and I don’t want to try hacking core, so hopefully the core team would consider to add a sensor with the firmware version or a binary sensor(true) when update is available.
@Robban Any chance you consider this(?)

No sorry that information is not available unless you can read it off of the device representing the gateway

Thanks for replying. Unfortunately, I am just a happy camper (user) when it comes to HA, have no clue diving into this.

From what I understand from CentralCommands reply " within that we have an API that looks like it gives you the firmware version in the response". Anyways, maybe something to have on the list for future feature.

Well, in my core.device_registry I have

        {
            "config_entries": [
                "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
            ],
            "connections": [],
            "identifiers": [
                [
                    "deconz",
                    "XXXXXXXXXXX"
                ]
            ],
            "manufacturer": "Dresden Elektronik",
            "model": "deCONZ",
            "name": "ConBee 2",
            "sw_version": "2.7.1",
            "entry_type": null,
            "id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
            "via_device_id": null,
            "area_id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
            "name_by_user": null,
            "disabled_by": null
        },

So that should be quite easy to extract using a command_line sensor.

Update 1:
command cat /config/.storage/core.device_registry | grep -A 3 "Dresden Elektronik" | grep "sw_version" | cut -c32-36 works for me (gives 2.7.1).

Update 2:

- platform: command_line
    name: deCONZ Firmware current
    command: 'cat /config/.storage/core.device_registry | grep -A 3 "Dresden Elektronik" | grep "sw_version" | cut -c32-36'
    scan_interval: 3600
    command_timeout: 60
    value_template: "{{ value }}"

But I wanted to dive into https://dresden-elektronik.github.io/deconz-rest-doc/endpoints/configuration/#get-configuration cause that seems to be the much more elegant way and is much more reliable. I have the API-URL (just use http://your-homeassistant-url:40850 and make sure that port is made available in addon configuration) but absolutely no idea on how to communicate with it. What´s the syntax? curl "http://your-homeassistant-url:40850 POST /api" e. g. does nothing, I´m not familiar enough with it.

Do not know how I missed that. Did find it now. Great! :smiley:
Sorry I can’t contribute on the API approach…

Yeah but we still need at least the latest version from Github which is not beta to compare it with the current version.

The latest_release_tag attribute from GitHub is not sufficient for this. Any ideas? We need a list of all versions and grab the newest one which is not “-beta”.

After that we can make a simple current vs. latest (non-beta) version comparison and proceed for creating the sensor, building proper notifications etc.

Something like:

sensor:
  # Deconz Firmware version installed
  - platform: command_line
    name: deCONZ Firmware installed
    command: 'cat /config/.storage/core.device_registry | grep -A 3 "Dresden Elektronik" | grep "sw_version" | cut -c32-36'
    scan_interval: 43200
    command_timeout: 60
    value_template: "{{ value }}"
binary_sensor:
  - platform: template
    sensors:
      updater_deconz:
        friendly_name: 'deConz ConbeeI firmware Updater'
        icon_template: mdi:update
        value_template: >-
          {% set new = state_attr('sensor.deconz_github', 'latest_release_tag').replace('v', '') %}
          {% if ("beta" not in new) and (new != states('binary_sensor.deconz_firmware_installed')).format() %}
            true
          {% else %}
            false
          {% endif %}

Ops…

Right. BUT how to cut the string. Currently the latest_release_tag gives “v2.9.0-beta” which is a string that can not be compared to an int/float.

Tried to use

{% set version = "v2.9.0-beta" | regex_findall_index('=([0-9]*\.[0-9]*.[0-9])', 0) %}
        {{ version }}

in the dev tools (template section) but I get a IndexError: list index out of range so the regex is not working…