[SOLVED] Extract Device Info for monitoring

Hi everyone,

I would like to monitor the FW version of my enphase gateway, but don’t have a sensor or other entity providing this info. I also did not find an appropriate action.

I just can see the FW version in the device info:
image

Is there a way to extract this information?

Thanks!

Based on How to enumerate entities belonging to an integration? you can use something like below.

The firmware version is only collected when the integration is loaded or reloaded. So it’s pretty static. When the Envoy firmware is updated there’s going to be an outage. But that may not lead to an integration reload in all cases. Some logic tries to detect such situations, but that needs some further fine-tuning.

They have some one-line examples in the thread as well, but that’s not my stronghold.

{%- set envoy = '123456789012' %}
{%- set devices = states | map(attribute='entity_id') | map('device_id') | unique | reject('eq',None) | list %}
{%- set ns = namespace(integrations = []) %}
{%- for device in devices %}
 {%- set ids = device_attr(device, 'identifiers') | list | first | default %}
  {%- if ids and ids | length == 2 %}
    {%- set integration, something_unique = ids %}
    {%- if integration == 'enphase_envoy' and something_unique == envoy and not device_attr(device, 'via_device_id') %}
      {%- set ns.integrations = ns.integrations + [ device_attr(device, 'sw_version') ] %}
    {%- endif %}
  {%- endif %}
{%- endfor %}
{%- set envoy_fw = ns.integrations | first | default %}
{{envoy_fw}}

Thank you.
It’s working in the template section of developer tools, but I don’t get it to work in an automation like this:

service: input_text.set_value
target:
  entity_id: input_text.enphase_gateway_fw
data_template:
  value: >-
    {%- set envoy = '098765432100' %}
    {%- set devices = states | map(attribute='entity_id') | map('device_id') | unique | reject('eq',None) | list %}
    {%- set ns = namespace(integrations = []) %}
    {%- for device in devices %}
     {%- set ids = device_attr(device, 'identifiers') | list | first | default %}
      {%- if ids and ids | length == 2 %}
        {%- set integration, something_unique = ids %}
        {%- if integration == 'enphase_envoy' and something_unique == envoy and not device_attr(device, 'via_device_id') %}
          {%- set ns.integrations = ns.integrations + [ device_attr(device, 'sw_version') ] %}
        {%- endif %}
      {%- endif %}
    {%- endfor %}
    {%- set envoy_fw = ns.integrations | first | default %}
    {{envoy_fw}}

The Code is accepted by the automation, but does not write it to the input_text entity.

EDIT:
Disregard - I got it and changed the code above accordingly