select.meshcore_discovered_contact This script no longer works after update?

Open
#219 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 11 days

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
Half a day
Newbie friendliness
18/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
mysql, python, yaml
Domain
backend

Research direction

The failing script is a Home Assistant automation in YAML, and the payload does not show which integration code produces the adv_name or friendly_name attributes that changed after the update. Start by checking whether binary_sensor entities named like meshcore_*_contact still carry an adv_name attribute, then find where the integration sets attributes for discovered contacts. Done means the template renders without a NoneType error and the reporter's notify action runs.

Written by the indexing model from the issue text.

Description

question

triggers:

  • trigger: state
    entity_id: select.meshcore_discovered_contact
    conditions: []
    actions:
  • variables:
    zoek_naam: " {% set mesh_contacts = states.binary_sensor | selectattr('entity_id', 'search', 'meshcore') | selectattr('entity_id', 'search', 'contact') | sort(attribute='last_changed', reverse=true) | list %} {% set test = mesh_contacts[0].attributes.friendly_name | replace('(Repeater)', '') | replace('(Client)', '') | replace('(Room Server)', '') %} {{ test }}"
    zoek_clean: "{{ zoek_naam | lower | replace('
    ', '') | replace(' ', '') }}"
    gevonden_sensor: |
    {% set sensors = states.binary_sensor
    | selectattr('entity_id', 'search', 'meshcore')
    | selectattr('attributes.adv_name', 'defined')
    | list %}
    {% set ns = namespace(found=none) %} {% for s in sensors %}
    {% set sensor_clean = s.attributes.adv_name | lower | replace('_', '') | replace(' ', '') %}
    {% if sensor_clean == zoek_clean %}
    {% set ns.found = s.entity_id %}
    {% endif %}
    {% endfor %} {{ ns.found }}
  • if:
    • condition: template
      value_template: "{{ gevonden_sensor != 'None' }}"
      then: null
  • action: notify.mysql_command_example_db
    metadata: {}
    data:
    message: |-
    {% set
    lat = state_attr(gevonden_sensor, 'latitude') %} {% set lon =
    state_attr(gevonden_sensor, 'longitude') %}{% set ad =
    state_attr(gevonden_sensor, 'last_advert_formatted') %}
    INSERT INTO advert (id, naam, tijd, kanaal, bericht, locatie, afstand,
    route, hops, snr, rssi, advert, type, typenode, datum, datumcontrole) VALUES ( '', '{{
    zoek_naam }}', '{{ now().strftime("%Y-%m-%d %H:%M:%S") }}', '', '',
    'https://www.google.com/maps/@?api=1&map_action=pano&viewpoint={{lat}},{{lon}}&heading=GETAL&pitch=GETAL',
    '{% set km = distance(gevonden_sensor) | float(0) %} {{ (km * 1000) |
    round(0) ~ " m" if km < 1 else km | round(2) ~ " km" }}', '', '',
    '', '', '{{ ad }}', 'advert', '{{
    state_attr(gevonden_sensor, "node_type_str") }}', '{{ now().strftime("%Y-%m-%d") }}', '{{ now().strftime("%Y-%m-%dT%H:%M:%S") }}'
    );

mode: single

Fout: Error rendering data template: AttributeError: 'NoneType' object has no attribute 'lower'

Maybe the script wasn't well written, but it worked.
Do I need to access the contact details differently after the update?

Dominant language
Python
Stars
269
Forks
58
Avg merge
10d 17h
Merged PRs (30d)
12

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from meshcore-dev/meshcore-ha

All issues in meshcore-dev/meshcore-ha

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.