gadjet
(gadjet)
June 27, 2022, 3:24pm
1
Hi,
I’ve recently installed HA and I’m slowly getting it configured and I’ve now got my MQTT messages to be received and I can see the values in the dashboards.
Can I add names to the MQTT entities? at the moment they are sensor.mqtt_sensor_1, sensor.mqtt_sensor_2 etc. is there any way to give them a name?, I know you can once in a
dashboard but want edit the entity name.
Cheers
francisp
(Francis)
June 27, 2022, 3:35pm
2
Settings → Devices and services → Entities → search your entity → Click on it →
Change entity ID and click on update
gadjet
(gadjet)
June 27, 2022, 4:06pm
3
Thanks but that doesn’t work as the MQTT entities are read only.
It there a way to add a friendly name in the configuration.yaml where the mqtt message is defined?
francisp
(Francis)
June 28, 2022, 2:40am
6
I see. You defined it in .yaml, and did not add an unique id.
Pre 2022.06, under sensor: or in sensor.yaml :
- platform: mqtt
name: "5 Active Power"
state_topic: "electricity5/tele/RESULT"
value_template: >-
{% set message = value_json.SerialReceived %}
{% set payload = message[38:46] %}
{% set payload_len = (payload | length) %}
{% set result = namespace(value='') %}
{% for i in range(0, payload_len + 1) | reverse -%}
{%- if i is divisibleby 2 -%}
{%- set result.value = result.value + payload[i:i+2] -%}
{%- endif -%}
{%- endfor -%}
{{ (result.value|float(0)) / 100 }}
unit_of_measurement: 'W'
unique_id: "5_active_power"
2022.6 or later: , under mqtt: or in mqtt.yaml
- name: "5 Active Power"
state_topic: "electricity5/tele/RESULT"
value_template: >-
{% set message = value_json.SerialReceived %}
{% set payload = message[38:46] %}
{% set payload_len = (payload | length) %}
{% set result = namespace(value='') %}
{% for i in range(0, payload_len + 1) | reverse -%}
{%- if i is divisibleby 2 -%}
{%- set result.value = result.value + payload[i:i+2] -%}
{%- endif -%}
{%- endfor -%}
{{ (result.value|float(0)) / 100 }}
unit_of_measurement: 'W'
unique_id: "5_active_power"
1 Like