Koenkk / zigbee2mqtt

Zigbee 🐝 to MQTT bridge 🌉, get rid of your proprietary Zigbee bridges 🔨
https://www.zigbee2mqtt.io
GNU General Public License v3.0
11.66k stars 1.64k forks source link

Xiaomi Aqara Temperature Sensor - Friendly Name in Entity Name? #138

Closed jarrah31 closed 6 years ago

jarrah31 commented 6 years ago

I'm starting to test/integrate my other Xiaomi devices with zigbee2mqtt and noticed that the Aqara temperature sensor (WSDCGQ11LM) entity name doesn't change to include the friendly name like the door sensors do. Is this normal/expected behaviour?

e.g. Z2M configuration.yaml:

devices:
  '0x00158d0001b149eb':
    friendly_name: window_ensuite_velux
  '0x00158d000245b389':
    friendly_name: window_bed2_mainleft
  '0x00158d0001b9560f':
    friendly_name: temperature_test

After a Z2M and HA restart, the temp sensor looks like this:

screen shot 2018-06-21 at 20 45 13

Whereas the door sensor looks like this:

screen shot 2018-06-21 at 20 46 07

Also, I notice that the actual values aren't showing up correctly on the states page either...

Thanks in advance!

Koenkk commented 6 years ago

After you change the name you need to reset zigbee2mqtt first and than home assistant. Did you do this?

jarrah31 commented 6 years ago

Hi @Koenkk - just to confirm I'm doing this right, I do restart zigbee2mqtt first with sudo systemctl restart zigbee2mqtt, wait for that to load and then restart HA.

I've restarted both a couple of times now and am just gathering logs in case it helps, especially with the missing temp values. :(

Koenkk commented 6 years ago

It could be that the old entity is not cleared, could you:

jarrah31 commented 6 years ago

Unfortunately that didn't work either - both the sensor values and entity names remain as seen in the screenshot above.

Hastebin isn't working/saving for me atm, so apologies for the logs being included below.

Jun 21 21:04:21 zigbeepi npm[19366]: 2018-6-21 21:04:21 INFO Starting zigbee-shepherd
Jun 21 21:04:21 zigbeepi npm[19366]: 2018-6-21 21:04:21 INFO zigbee-shepherd started
Jun 21 21:04:21 zigbeepi npm[19366]: 2018-6-21 21:04:21 INFO Currently 3 devices are joined:
Jun 21 21:04:21 zigbeepi npm[19366]: 2018-6-21 21:04:21 INFO window_ensuite_velux (0x00158d0001b149eb): MCCGQ11LM - Xiaomi Aqara door & window contact sensor (EndDevice)
Jun 21 21:04:21 zigbeepi npm[19366]: 2018-6-21 21:04:21 INFO window_bed2_mainleft (0x00158d000245b389): MCCGQ11LM - Xiaomi Aqara door & window contact sensor (EndDevice)
Jun 21 21:04:21 zigbeepi npm[19366]: 2018-6-21 21:04:21 INFO temperature_test (0x00158d0001b9560f): WSDCGQ11LM - Xiaomi Aqara temperature, humidity and pressure sensor (EndDevice)
Jun 21 21:04:21 zigbeepi npm[19366]: 2018-6-21 21:04:21 WARN `permit_join` set to  `true` in configuration.yaml.
Jun 21 21:04:21 zigbeepi npm[19366]: 2018-6-21 21:04:21 WARN Allowing new devices to join.
Jun 21 21:04:21 zigbeepi npm[19366]: 2018-6-21 21:04:21 WARN Set `permit_join` to `false` once you joined all devices.
Jun 21 21:04:21 zigbeepi npm[19366]: 2018-6-21 21:04:21 INFO Zigbee: allowing new devices to join.
Jun 21 21:04:21 zigbeepi npm[19366]: 2018-6-21 21:04:21 INFO Connecting to MQTT server at mqtt://192.168.1.50
Jun 21 21:04:22 zigbeepi npm[19366]: 2018-6-21 21:04:22 INFO zigbee-shepherd ready
Jun 21 21:04:32 zigbeepi npm[19366]: 2018-6-21 21:04:32 ERROR Not connected to MQTT server!

Jun 21 21:04:42 zigbeepi npm[19366]: 2018-6-21 21:04:42 ERROR Not connected to MQTT server!
Jun 21 21:04:52 zigbeepi npm[19366]: 2018-6-21 21:04:52 ERROR Not connected to MQTT server!
Jun 21 21:05:02 zigbeepi npm[19366]: 2018-6-21 21:05:02 ERROR Not connected to MQTT server!
Jun 21 21:05:12 zigbeepi npm[19366]: 2018-6-21 21:05:12 ERROR Not connected to MQTT server!
Jun 21 21:05:22 zigbeepi npm[19366]: 2018-6-21 21:05:22 ERROR Not connected to MQTT server!
Jun 21 21:05:25 zigbeepi npm[19366]: 2018-6-21 21:05:25 INFO Connected to MQTT server
Jun 21 21:05:25 zigbeepi npm[19366]: 2018-6-21 21:05:25 INFO MQTT publish, topic: 'zigbee2mqtt/bridge/state', payload: 'online'
Jun 21 21:05:25 zigbeepi npm[19366]: 2018-6-21 21:05:25 INFO MQTT publish, topic: 'homeassistant/binary_sensor/0x00158d0001b149eb/contact/config', payload: '{"payload_on":false,"payload_off":true,"value_template":"{{ value_json.contact }}","device_class":"door","json_attributes":["battery","voltage"],"state_topic":"zigbee2mqtt/window_ensuite_velux","availability_topic":"zigbee2mqtt/bridge/state","name":"window_ensuite_velux","unique_id":"0x00158d0001b149eb_contact_zigbee2mqtt"}'
Jun 21 21:05:25 zigbeepi npm[19366]: 2018-6-21 21:05:25 INFO MQTT publish, topic: 'homeassistant/binary_sensor/0x00158d000245b389/contact/config', payload: '{"payload_on":false,"payload_off":true,"value_template":"{{ value_json.contact }}","device_class":"door","json_attributes":["battery","voltage"],"state_topic":"zigbee2mqtt/window_bed2_mainleft","availability_topic":"zigbee2mqtt/bridge/state","name":"window_bed2_mainleft","unique_id":"0x00158d000245b389_contact_zigbee2mqtt"}'
Jun 21 21:05:25 zigbeepi npm[19366]: 2018-6-21 21:05:25 INFO MQTT publish, topic: 'homeassistant/sensor/0x00158d0001b9560f/temperature/config', payload: '{"unit_of_measurement":"°C","icon":"mdi:temperature-celsius","value_template":"{{ value_json.temperature }}","json_attributes":["battery","voltage"],"state_topic":"zigbee2mqtt/temperature_test","availability_topic":"zigbee2mqtt/bridge/state","name":"temperature_test_temperature","unique_id":"0x00158d0001b9560f_temperature_zigbee2mqtt"}'
Jun 21 21:05:25 zigbeepi npm[19366]: 2018-6-21 21:05:25 INFO MQTT publish, topic: 'homeassistant/sensor/0x00158d0001b9560f/humidity/config', payload: '{"unit_of_measurement":"%","icon":"mdi:water-percent","value_template":"{{ value_json.humidity }}","json_attributes":["battery","voltage"],"state_topic":"zigbee2mqtt/temperature_test","availability_topic":"zigbee2mqtt/bridge/state","name":"temperature_test_humidity","unique_id":"0x00158d0001b9560f_humidity_zigbee2mqtt"}'
Jun 21 21:05:25 zigbeepi npm[19366]: 2018-6-21 21:05:25 INFO MQTT publish, topic: 'homeassistant/sensor/0x00158d0001b9560f/pressure/config', payload: '{"unit_of_measurement":"Pa","icon":"mdi:speedometer","value_template":"{{ value_json.pressure }}","json_attributes":["battery","voltage"],"state_topic":"zigbee2mqtt/temperature_test","availability_topic":"zigbee2mqtt/bridge/state","name":"temperature_test_pressure","unique_id":"0x00158d0001b9560f_pressure_zigbee2mqtt"}'
Jun 21 21:13:08 zigbeepi npm[19366]: 2018-6-21 21:13:08 INFO MQTT publish, topic: 'zigbee2mqtt/temperature_test', payload: '{"battery":"57.00","voltage":3085}'
Jun 21 21:17:50 zigbeepi npm[19366]: 2018-6-21 21:17:50 INFO MQTT publish, topic: 'zigbee2mqtt/temperature_test', payload: '{"battery":"57.00","voltage":3085,"temperature":25.42}'
Jun 21 21:17:50 zigbeepi npm[19366]: 2018-6-21 21:17:50 INFO MQTT publish, topic: 'zigbee2mqtt/temperature_test', payload: '{"battery":"57.00","voltage":3085,"temperature":25.42,"humidity":46.18}'
Jun 21 21:17:50 zigbeepi npm[19366]: 2018-6-21 21:17:50 INFO MQTT publish, topic: 'zigbee2mqtt/temperature_test', payload: '{"battery":"57.00","voltage":3085,"temperature":25.42,"humidity":46.18,"pressure":1020}'

HA Logs

2018-06-21 21:05:08 INFO (MainThread) [homeassistant.setup] Setting up mqtt
2018-06-21 21:05:08 INFO (MainThread) [homeassistant.loader] Loaded mqtt.server from homeassistant.components.mqtt.server
2018-06-21 21:05:17 INFO (MainThread) [hbmqtt.broker] Listener 'default' bind to 0.0.0.0:1883 (max_connections=-1)
2018-06-21 21:05:17 INFO (MainThread) [hbmqtt.broker] Listener 'ws-1' bind to 0.0.0.0:8080 (max_connections=-1)
2018-06-21 21:05:17 INFO (MainThread) [homeassistant.loader] Loaded mqtt.discovery from homeassistant.components.mqtt.discovery
2018-06-21 21:05:17 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to homeassistant/#
2018-06-21 21:05:17 INFO (MainThread) [homeassistant.setup] Setup of domain mqtt took 9.0 seconds.
2018-06-21 21:05:17 INFO (MainThread) [hbmqtt.broker] Listener 'default': 1 connections acquired
2018-06-21 21:05:17 INFO (MainThread) [hbmqtt.broker] Connection from 127.0.0.1:59299 on listener 'default'
2018-06-21 21:05:21 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to homeassistant/#
2018-06-21 21:05:21 INFO (MainThread) [hbmqtt.broker] Listener 'default': 2 connections acquired
2018-06-21 21:05:21 INFO (MainThread) [hbmqtt.broker] Connection from 192.168.1.58:33132 on listener 'default'
2018-06-21 21:05:25 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on homeassistant/binary_sensor/0x00158d0001b149eb/contact/config: b'{"payload_on":false,"payload_off":true,"value_template":"{{ value_json.contact }}","device_class":"door","json_attributes":["battery","voltage"],"state_topic":"zigbee2mqtt/window_ensuite_velux","availability_topic":"zigbee2mqtt/bridge/state","name":"window_ensuite_velux","unique_id":"0x00158d0001b149eb_contact_zigbee2mqtt"}'
2018-06-21 21:05:25 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: binary_sensor 0x00158d0001b149eb_contact
2018-06-21 21:05:25 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on homeassistant/binary_sensor/0x00158d000245b389/contact/config: b'{"payload_on":false,"payload_off":true,"value_template":"{{ value_json.contact }}","device_class":"door","json_attributes":["battery","voltage"],"state_topic":"zigbee2mqtt/window_bed2_mainleft","availability_topic":"zigbee2mqtt/bridge/state","name":"window_bed2_mainleft","unique_id":"0x00158d000245b389_contact_zigbee2mqtt"}'
2018-06-21 21:05:25 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: binary_sensor 0x00158d000245b389_contact
2018-06-21 21:05:25 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on homeassistant/sensor/0x00158d0001b9560f/temperature/config: b'{"unit_of_measurement":"\xc2\xb0C","icon":"mdi:temperature-celsius","value_template":"{{ value_json.temperature }}","json_attributes":["battery","voltage"],"state_topic":"zigbee2mqtt/temperature_test","availability_topic":"zigbee2mqtt/bridge/state","name":"temperature_test_temperature","unique_id":"0x00158d0001b9560f_temperature_zigbee2mqtt"}'
2018-06-21 21:05:25 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on homeassistant/sensor/0x00158d0001b9560f/humidity/config: b'{"unit_of_measurement":"%","icon":"mdi:water-percent","value_template":"{{ value_json.humidity }}","json_attributes":["battery","voltage"],"state_topic":"zigbee2mqtt/temperature_test","availability_topic":"zigbee2mqtt/bridge/state","name":"temperature_test_humidity","unique_id":"0x00158d0001b9560f_humidity_zigbee2mqtt"}'
2018-06-21 21:05:25 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: sensor 0x00158d0001b9560f_temperature
2018-06-21 21:05:25 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: sensor 0x00158d0001b9560f_humidity
2018-06-21 21:05:28 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on homeassistant/sensor/0x00158d0001b9560f/pressure/config: b'{"unit_of_measurement":"Pa","icon":"mdi:speedometer","value_template":"{{ value_json.pressure }}","json_attributes":["battery","voltage"],"state_topic":"zigbee2mqtt/temperature_test","availability_topic":"zigbee2mqtt/bridge/state","name":"temperature_test_pressure","unique_id":"0x00158d0001b9560f_pressure_zigbee2mqtt"}'
2018-06-21 21:05:32 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: sensor 0x00158d0001b9560f_pressure
2018-06-21 21:05:37 INFO (MainThread) [homeassistant.loader] Loaded sensor.mqtt from homeassistant.components.sensor.mqtt
2018-06-21 21:05:37 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.mqtt
2018-06-21 21:05:37 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.mqtt
2018-06-21 21:05:37 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.mqtt
2018-06-21 21:05:38 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to zigbee2mqtt/bridge/state
2018-06-21 21:05:38 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to zigbee2mqtt/bridge/state
2018-06-21 21:05:38 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to zigbee2mqtt/bridge/state
2018-06-21 21:05:38 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to zigbee2mqtt/temperature_test
2018-06-21 21:05:38 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to zigbee2mqtt/temperature_test
2018-06-21 21:05:38 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to zigbee2mqtt/temperature_test
2018-06-21 21:05:38 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on zigbee2mqtt/bridge/state: b'online'
2018-06-21 21:05:38 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on zigbee2mqtt/bridge/state: b'online'
2018-06-21 21:05:38 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on zigbee2mqtt/bridge/state: b'online'
2018-06-21 21:05:44 INFO (MainThread) [homeassistant.loader] Loaded binary_sensor.mqtt from homeassistant.components.binary_sensor.mqtt
2018-06-21 21:05:44 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up binary_sensor.mqtt
2018-06-21 21:05:44 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up binary_sensor.mqtt
2018-06-21 21:05:44 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to zigbee2mqtt/bridge/state
2018-06-21 21:05:44 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to zigbee2mqtt/bridge/state
2018-06-21 21:05:44 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to zigbee2mqtt/window_ensuite_velux
2018-06-21 21:05:44 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to zigbee2mqtt/window_bed2_mainleft
2018-06-21 21:05:44 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on zigbee2mqtt/bridge/state: b'online'
2018-06-21 21:05:44 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on zigbee2mqtt/bridge/state: b'online'
jarrah31 commented 6 years ago

Looks like the sensor values are appearing now - I should be more patient!! Just a thought, could the temp sensor values be reposted after a HA reconnect like we do with the door sensor to try and avoid the unknown state?

Entity names remain the same though.

Koenkk commented 6 years ago

The states should already be reposted.

Can you post your zigbee2mqtt configuration.yaml (devices only) and the entity names in HA?

jarrah31 commented 6 years ago

Sure - zigbee2mqtt configuration.yaml:

homeassistant: true
permit_join: true
mqtt:
  base_topic: zigbee2mqtt
  server: 'mqtt://192.168.1.50'
  user: homeassistant
  password: removed
serial:
  port: /dev/ttyACM0
devices:
  '0x00158d0001b149eb':
    friendly_name: window_ensuite_velux
  '0x00158d000245b389':
    friendly_name: window_bed2_mainleft
  '0x00158d0001b9560f':
    friendly_name: temperature_test
advanced:
  log_level: debug
screen shot 2018-06-21 at 20 45 13

I'm going to open a new issue for the problem where sensor data shows as unknown because it seems sensor values aren't sent to HA after a zigbee2mqtt restart. Only after waiting ~10 mins until a new set of values have been received on zigbee2mqtt are they then sent onto HA. Would you be happy with me doing this?

Koenkk commented 6 years ago

Yes of course!

Are you sure there isn't a e.g. sensor.temperature_test_temperature in HA?

If so, can you post your startup log of zigbee2mqtt.

jarrah31 commented 6 years ago

Yep, note the find count of 3/3 in the screenshot below:

screen shot 2018-06-21 at 21 50 58

Startup log:

Jun 21 21:28:19 zigbeepi systemd[1]: Started zigbee2mqtt.
Jun 21 21:28:21 zigbeepi npm[19428]: > zigbee2mqtt@0.1.0 start /opt/zigbee2mqtt
Jun 21 21:28:21 zigbeepi npm[19428]: > node index.js
Jun 21 21:28:22 zigbeepi npm[19428]: 2018-6-21 21:28:22 INFO Starting zigbee-shepherd
Jun 21 21:28:23 zigbeepi npm[19428]: 2018-6-21 21:28:23 INFO zigbee-shepherd started
Jun 21 21:28:23 zigbeepi npm[19428]: 2018-6-21 21:28:23 INFO Currently 3 devices are joined:
Jun 21 21:28:23 zigbeepi npm[19428]: 2018-6-21 21:28:23 INFO window_ensuite_velux (0x00158d0001b149eb): MCCGQ11LM - Xiaomi Aqara door & window contact sensor (EndDevice)
Jun 21 21:28:23 zigbeepi npm[19428]: 2018-6-21 21:28:23 INFO window_bed2_mainleft (0x00158d000245b389): MCCGQ11LM - Xiaomi Aqara door & window contact sensor (EndDevice)
Jun 21 21:28:23 zigbeepi npm[19428]: 2018-6-21 21:28:23 INFO temperature_test (0x00158d0001b9560f): WSDCGQ11LM - Xiaomi Aqara temperature, humidity and pressure sensor (EndDevice)
Jun 21 21:28:23 zigbeepi npm[19428]: 2018-6-21 21:28:23 WARN `permit_join` set to  `true` in configuration.yaml.
Jun 21 21:28:23 zigbeepi npm[19428]: 2018-6-21 21:28:23 WARN Allowing new devices to join.
Jun 21 21:28:23 zigbeepi npm[19428]: 2018-6-21 21:28:23 WARN Set `permit_join` to `false` once you joined all devices.
Jun 21 21:28:23 zigbeepi npm[19428]: 2018-6-21 21:28:23 INFO Zigbee: allowing new devices to join.
Jun 21 21:28:23 zigbeepi npm[19428]: 2018-6-21 21:28:23 INFO Connecting to MQTT server at mqtt://192.168.1.50
Jun 21 21:28:23 zigbeepi npm[19428]: 2018-6-21 21:28:23 INFO zigbee-shepherd ready
Jun 21 21:28:27 zigbeepi npm[19428]: 2018-6-21 21:28:27 INFO Connected to MQTT server
Jun 21 21:28:27 zigbeepi npm[19428]: 2018-6-21 21:28:27 INFO MQTT publish, topic: 'zigbee2mqtt/bridge/state', payload: 'online'
Jun 21 21:28:27 zigbeepi npm[19428]: 2018-6-21 21:28:27 INFO MQTT publish, topic: 'homeassistant/binary_sensor/0x00158d0001b149eb/contact/config', payload: '{"payload_on":false,"payload_off":true,"value_template":"{{ value_json.contact }}","device_class":"door","json_attributes":["battery","voltage"],"state_topic":"zigbee2mqtt/window_ensuite_velux","availability_topic":"zigbee2mqtt/bridge/state","name":"window_ensuite_velux","unique_id":"0x00158d0001b149eb_contact_zigbee2mqtt"}'
Jun 21 21:28:27 zigbeepi npm[19428]: 2018-6-21 21:28:27 INFO MQTT publish, topic: 'homeassistant/binary_sensor/0x00158d000245b389/contact/config', payload: '{"payload_on":false,"payload_off":true,"value_template":"{{ value_json.contact }}","device_class":"door","json_attributes":["battery","voltage"],"state_topic":"zigbee2mqtt/window_bed2_mainleft","availability_topic":"zigbee2mqtt/bridge/state","name":"window_bed2_mainleft","unique_id":"0x00158d000245b389_contact_zigbee2mqtt"}'
Jun 21 21:28:27 zigbeepi npm[19428]: 2018-6-21 21:28:27 INFO MQTT publish, topic: 'homeassistant/sensor/0x00158d0001b9560f/temperature/config', payload: '{"unit_of_measurement":"°C","icon":"mdi:temperature-celsius","value_template":"{{ value_json.temperature }}","json_attributes":["battery","voltage"],"state_topic":"zigbee2mqtt/temperature_test","availability_topic":"zigbee2mqtt/bridge/state","name":"temperature_test_temperature","unique_id":"0x00158d0001b9560f_temperature_zigbee2mqtt"}'
Jun 21 21:28:27 zigbeepi npm[19428]: 2018-6-21 21:28:27 INFO MQTT publish, topic: 'homeassistant/sensor/0x00158d0001b9560f/humidity/config', payload: '{"unit_of_measurement":"%","icon":"mdi:water-percent","value_template":"{{ value_json.humidity }}","json_attributes":["battery","voltage"],"state_topic":"zigbee2mqtt/temperature_test","availability_topic":"zigbee2mqtt/bridge/state","name":"temperature_test_humidity","unique_id":"0x00158d0001b9560f_humidity_zigbee2mqtt"}'
Jun 21 21:28:27 zigbeepi npm[19428]: 2018-6-21 21:28:27 INFO MQTT publish, topic: 'homeassistant/sensor/0x00158d0001b9560f/pressure/config', payload: '{"unit_of_measurement":"Pa","icon":"mdi:speedometer","value_template":"{{ value_json.pressure }}","json_attributes":["battery","voltage"],"state_topic":"zigbee2mqtt/temperature_test","availability_topic":"zigbee2mqtt/bridge/state","name":"temperature_test_pressure","unique_id":"0x00158d0001b9560f_pressure_zigbee2mqtt"}'
Jun 21 21:28:27 zigbeepi npm[19428]: 2018-6-21 21:28:27 DEBUG Recieved mqtt message on topic 'hass/status' with data 'online'
Koenkk commented 6 years ago

@ciotlosm Could it be the the unique_id is used as name instead of the name here?

ciotlosm commented 6 years ago

@Koenkk Indeed this might be a bug.

https://github.com/Koenkk/zigbee2mqtt/blob/master/lib/homeassistant.js#L307 should be corrected in one of two ways:

The first one should have correct results (based on what I've seen in the screenshots above), but I can test later. Users will lose the ability to rename in home assistant the sensor if they set friendly_name in zigbee2mqtt

The second one can be tricky, as I could get side effects if friendly_name is very common and you get duplicates.

Koenkk commented 6 years ago

What if we go for option 2 (Allow unique_id every time, but set it to friendly_name in case the user set it) and only allow unique friendly_name in configuration.yaml (checked on start of zigbee2mqtt)?

ciotlosm commented 6 years ago

That would work, but if the user still sets something very generic like "bedroom" it will create errors in home assistant if he has another entity setup by the same name. I know it's up to the users to make sure they don't setup duplicates, but would be also less issues reported that stuff doesn't work.

jarrah31 commented 6 years ago

I've just tested your latest commit to see if it would help but I'm afraid HA still shows the unique id for the entity name. I did a full shutdown as suggested earlier in the thread.

I've added another Xiaomi device (Xiaomi Aqara wireless switch - WXKG11LM) and this also doesn't have the friendly name set as the entity id.

One thing I've noticed is that a sensor. entity doesn't use the friendly name, whereas binary_sensor. does use the friendly name.

I agree that it's the users responsibility to set a unique name - the benefits of being able to set a friendly entity name are huge. If we are able to fix this then it would be a major advantage over the Xiaomi HA implementation which only has unique ids.

Koenkk commented 6 years ago

Can you provide your zigbee2mqtt startup log?

I've tested myself and when a friendly_name is set, unique_id is not included in the homeassistant configure message: https://hastebin.com/aditoqapet.scala (1 with and 1 without friendly_name).

jarrah31 commented 6 years ago

Sure: https://hastebin.com/adosiweveb.scala

Just curious to see if you could set your sensor (the IKEA TRADFRI wireless dimmer) to a friendly name instead of the switch please to see if it still works? I found that sensors were the ones not picking up the friendly name in my setup.

Koenkk commented 6 years ago

Are you sure you are running with 19f6d5f72a8ef0f608479ee1b9114ff6c2afe9bc? It's is in a different branch: https://github.com/Koenkk/zigbee2mqtt/commits/issue_138. Can you provide the commit hash which zigbee2mqtt prints on start?

jarrah31 commented 6 years ago

doh!!! really sorry, I didn't realise it was in a different branch, I just followed the usual update process. :(

After a quick git checkout I can confirm that friendly names now show up as the entity name... :) Sorry for the extra confusion and hassle.

My final issue is just the battery side of things now. :)

Koenkk commented 6 years ago

Ok, so this issue can be closed?

jarrah31 commented 6 years ago

Yep, happy for it to be closed, thanks for your help!

Koenkk commented 6 years ago

Great, thanks!

mihalski commented 5 years ago

I've been butting my head against the issue created by this pull request and was wondering, why not decouple the unique_id and friendly_name?

The unique_id could be calculated as if the user had not set the friendly_name for every occasion. Seems like this would be the perfect solution.