bieniu / ha-shellies-discovery-gen2

Script that adds MQTT discovery support for Shellies Gen2 devices
Apache License 2.0
106 stars 18 forks source link

MQTT device name is equal to entity name in your config #302

Closed dylan09 closed 1 year ago

dylan09 commented 1 year ago

Describe the bug I have one Shelly 1PM in my configuration. For this device I get a few Warning messages in HA logs:

Oct 31 16:57:14 haos.home.umartiensen.de homeassistant[559]: 2023-10-31 17:57:14.618 WARNING (MainThread) [homeassistant.components.mqtt.mixins] MQTT device name is equal to entity name in your config {'name': 'hz_sw_heizung', 'command_topic': 'shellies2/hz_sw_heizung/rpc', 'payload_off': '{"id":1,"src":"home-assistant","method":"Switch.Set","params":{"id":0,"on":false}}', 'payload_on': '{"id":1,"src":"home-assistant","method":"Switch.Set","params":{"id":0,"on":true}}', 'state_topic': 'shellies2/hz_sw_heizung/status/switch:0', 'value_template': Template<template=({%if value_json.output%}on{%else%}off{%endif%}) renders=0>, 'state_off': 'off', 'state_on': 'on', 'availability': [{'topic': 'shellies2/hz_sw_heizung/online', 'payload_available': 'true', 'payload_not_available': 'false'}, {'topic': 'shellies2/hz_sw_heizung/status/rpc', 'value_template': Template<template=({%if value_json.mqtt.connected%}online{%else%}offline{%endif%}) renders=0>, 'payload_available': 'online', 'payload_not_available': 'offline'}], 'unique_id': 'shellyplus1pm-a8032abe28ec-0', 'qos': 0, 'device': {'connections': [['mac', 'A8:03:2A:BE:28:EC']], 'name': 'hz_sw_heizung', 'model': 'Shelly Plus 1PM', 'sw_version': '20231031-152218/1.0.7-g5db02bd', 'hw_version': 'gen2 (SNSW-001P16EU)', 'manufacturer': 'Allterco Robotics', 'configuration_url': 'http://shellyplus1pm-a8032abe28ec.local/', 'identifiers': []}, 'origin': {'name': 'Shellies Discovery Gen2', 'sw_version': '2.20.0', 'support_url': 'https://github.com/bieniu/ha-shellies-discovery-gen2'}, 'retain': False, 'payload_not_available': 'offline', 'payload_available': 'online', 'encoding': 'utf-8', 'enabled_by_default': True, 'availability_mode': 'latest', 'optimistic': False}, this is not expected. Please correct your configuration. The entity name will be set to `null`

I am out of ideas. Have deleted the device from Home Assistant. Deleted all related entries from MQTT broker. Every time I start the script the warnings are back in log file. They are not there for all sensors. I get them for Energy, Frequency, Power, Temperature and a few other.

For Input 0, Firmware, Cloud, ... and others there are no error messages.

What else could I do, to get the entity names correct?

Expected behavior I hoped to get rid of the warnings.

Versions:

Shellies Discovery GEN2 automation:

- id: shellies_discovery_gen2
  alias: "Shellies Discovery Gen2"
  mode: queued
  max: 999
  trigger:
  - platform: mqtt
    topic: shellies_discovery/rpc
  action:
  - service: python_script.shellies_discovery_gen2
    data:
      id: "{{ trigger.payload_json.src }}"
      device_config: "{{ trigger.payload_json.result }}"
  - service: mqtt.publish
    data:
      topic: "{{ trigger.payload_json.result.mqtt.topic_prefix }}/command"
      payload: "status_update"

Debug log:

Oct 31 16:57:14 haos.home.umartiensen.de homeassistant[559]: 2023-10-31 17:57:14.618 WARNING (MainThread) [homeassistant.components.mqtt.mixins] MQTT device name is equal to entity name in your config {'name': 'hz_sw_heizung', 'command_topic': 'shellies2/hz_sw_heizung/rpc', 'payload_off': '{"id":1,"src":"home-assistant","method":"Switch.Set","params":{"id":0,"on":false}}', 'payload_on': '{"id":1,"src":"home-assistant","method":"Switch.Set","params":{"id":0,"on":true}}', 'state_topic': 'shellies2/hz_sw_heizung/status/switch:0', 'value_template': Template<template=({%if value_json.output%}on{%else%}off{%endif%}) renders=0>, 'state_off': 'off', 'state_on': 'on', 'availability': [{'topic': 'shellies2/hz_sw_heizung/online', 'payload_available': 'true', 'payload_not_available': 'false'}, {'topic': 'shellies2/hz_sw_heizung/status/rpc', 'value_template': Template<template=({%if value_json.mqtt.connected%}online{%else%}offline{%endif%}) renders=0>, 'payload_available': 'online', 'payload_not_available': 'offline'}], 'unique_id': 'shellyplus1pm-a8032abe28ec-0', 'qos': 0, 'device': {'connections': [['mac', 'A8:03:2A:BE:28:EC']], 'name': 'hz_sw_heizung', 'model': 'Shelly Plus 1PM', 'sw_version': '20231031-152218/1.0.7-g5db02bd', 'hw_version': 'gen2 (SNSW-001P16EU)', 'manufacturer': 'Allterco Robotics', 'configuration_url': 'http://shellyplus1pm-a8032abe28ec.local/', 'identifiers': []}, 'origin': {'name': 'Shellies Discovery Gen2', 'sw_version': '2.20.0', 'support_url': 'https://github.com/bieniu/ha-shellies-discovery-gen2'}, 'retain': False, 'payload_not_available': 'offline', 'payload_available': 'online', 'encoding': 'utf-8', 'enabled_by_default': True, 'availability_mode': 'latest', 'optimistic': False}, this is not expected. Please correct your configuration. The entity name will be set to `null`
bieniu commented 1 year ago

Is the device name in the device configuration the same as the output name (hz_sw_heizung)?

dylan09 commented 1 year ago

Yes. Same Name. And the MQTT prefix is shellies2/hz_sw_heizung

Will it work if I rename the device in Shelly Configuration?

bieniu commented 1 year ago

You should change the device name or the output name.