arendst / Tasmota

Alternative firmware for ESP8266 and ESP32 based devices with easy configuration using webUI, OTA updates, automation using timers or rules, expandability and entirely local control over MQTT, HTTP, Serial or KNX. Full documentation at
https://tasmota.github.io/docs
GNU General Public License v3.0
22.18k stars 4.81k forks source link

Fix HA Discovery regression to use Friendly Name again. #8306

Closed potto007 closed 4 years ago

potto007 commented 4 years ago

PROBLEM DESCRIPTION

The HA Discovery commit (3e47b6fe19a512181145da211e965ee0118e2814) introduced a regression to the HomeAssistant discovery interactions, resulting in the device name = model name. Upgrading to any firmware dated after 20200421-120032-1065381-tasmota.bin results in the device name being changed to the model name of that device within HomeAssistant.

REQUESTED INFORMATION

- [x] Provide the output of this command: `Status 0`:

21:27:56 MQT: stat/extra1/STATUS = {"Status":{"Module":0,"FriendlyName":["Extra 1"],"Topic":"extra1","ButtonTopic":"0","Power":0,"PowerOnState":3,"LedState":1,"LedMask":"FFFF","SaveData":1,"SaveState":1,"SwitchTopic":"0","SwitchMode":[0,0,0,0,0,0,0,0],"ButtonRetain":0,"SwitchRetain":0,"SensorRetain":0,"PowerRetain":0}} 21:27:56 MQT: stat/extra1/STATUS1 = {"StatusPRM":{"Baudrate":115200,"SerialConfig":"8N1","GroupTopic":"tasmotas","OtaUrl":"http://thehackbox.org/tasmota/tasmota.bin.gz ","RestartReason":"Software/System restart","Uptime":"0T00:01:28","StartupUTC":"2020-04-29T20:26:28","Sleep":50,"CfgHolder":4617,"BootCount":19,"BCResetTime":"2020-04-09T19:39:28","SaveCount":125,"SaveAddress":"F9000"}} 21:27:56 MQT: stat/extra1/STATUS2 = {"StatusFWR":{"Version":"8.2.0.5(2e725b7-tasmota)","BuildDateTime":"2020-04-29T21:00:14","Boot":31,"Core":"STAGE","SDK":"2.2.2-dev(38a443e)","Hardware":"ESP8266EX","CR":"379/699"}} 21:27:56 MQT: stat/extra1/STATUS3 = {"StatusLOG":{"SerialLog":2,"WebLog":2,"MqttLog":0,"SysLog":0,"LogHost":"","LogPort":514,"SSId":["Precise",""],"TelePeriod":300,"Resolution":"558180C0","SetOption":["00028009","2805C8000100060000005A00000000000000","00000200","00000000"]}} 21:27:56 MQT: stat/extra1/STATUS4 = {"StatusMEM":{"ProgramSize":585,"Free":416,"Heap":24,"ProgramFlashSize":1024,"FlashSize":1024,"FlashChipId":"144068","FlashMode":3,"Features":["00000809","8FDAE797","043683A0","000000CD","010013C0","C000F981","00000024"],"Drivers":"1,2,3,4,5,6,7,8,9,10,12,16,18,19,20,21,22,24,26,27,29,30,35,37","Sensors":"1,2,3,4,5,6"}} 21:27:56 MQT: stat/extra1/STATUS5 = {"StatusNET":{"Hostname":"extra1-1639","IPAddress":"10.4.0.238","Gateway":"10.4.0.1","Subnetmask":"255.255.255.0","DNSServer":"10.4.0.2","Mac":"80:7D:3A:7B:C6:67","Webserver":2,"WifiConfig":2,"WifiPower":17.0}} 21:27:56 MQT: stat/extra1/STATUS6 = {"StatusMQT":{"MqttHost":"homeassistant.ad.ottoops.com","MqttPort":1883,"MqttClientMask":"DVES_%06X","MqttClient":"DVES_7BC667","MqttUser":"mqtt","MqttCount":1,"MAX_PACKET_SIZE":1200,"KEEPALIVE":30}} 21:27:56 MQT: stat/extra1/STATUS7 = {"StatusTIM":{"UTC":"2020-04-29T20:27:56","Local":"2020-04-29T21:27:56","StartDST":"2020-03-29T02:00:00","EndDST":"2020-10-25T03:00:00","Timezone":"+01:00","Sunrise":"05:32","Sunset":"20:02"}} 21:27:56 MQT: stat/extra1/STATUS9 = {"StatusPTH":{"PowerDelta":0,"PowerLow":0,"PowerHigh":0,"VoltageLow":0,"VoltageHigh":0,"CurrentLow":0,"CurrentHigh":0}} 21:27:56 MQT: stat/extra1/STATUS10 = {"StatusSNS":{"Time":"2020-04-29T21:27:56","ENERGY":{"TotalStartTime":"2020-04-09T19:21:36","Total":0.022,"Yesterday":0.000,"Today":0.006,"Power":0,"ApparentPower":0,"ReactivePower":0,"Factor":0.00,"Voltage":0,"Current":0.000}}} 21:27:56 MQT: stat/extra1/STATUS11 = {"StatusSTS":{"Time":"2020-04-29T21:27:56","Uptime":"0T00:01:28","UptimeSec":88,"Heap":24,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":1,"POWER":"OFF","Wifi":{"AP":1,"SSId":"Precise","BSSId":"78:8A:20:DD:17:D5","Channel":11,"RSSI":80,"Signal":-60,"LinkCount":1,"Downtime":"0T00:00:04"}}}

- [x] Provide the output of the Console log output when you experience your issue; if applicable:
  _(Please use_ `weblog 4` _for more debug information)_

21:29:18 CMD: SetOption19 1 21:29:18 SRC: WebConsole from 10.4.0.209 21:29:18 CMD: Group 0, Index 19, Command "SETOPTION", Data "1" 21:29:18 MQT: stat/extra1/RESULT = {"SetOption19":"ON"} 21:29:19 MQT: homeassistant/sensor/7BC667_ENERGY_Total/config = {"name":"Extra 1 ENERGY Total","stat_t":"tele/extra1/SENSOR","avty_t":"tele/extra1/LWT","pl_avail":"Online","pl_not_avail":"Offline","uniq_id":"7BC667_ENERGY_Total","dev":{"ids":["7BC667"]},"unit_of_meas":"kWh","dev_cla":"power","frc_upd":true,"val_tpl":"{{value_json['ENERGY']['Total']}}"} (retained) 21:29:19 MQT: homeassistant/sensor/7BC667_ENERGY_Yesterday/config = {"name":"Extra 1 ENERGY Yesterday","stat_t":"tele/extra1/SENSOR","avty_t":"tele/extra1/LWT","pl_avail":"Online","pl_not_avail":"Offline","uniq_id":"7BC667_ENERGY_Yesterday","dev":{"ids":["7BC667"]},"unit_of_meas":"kWh","dev_cla":"power","frc_upd":true,"val_tpl":"{{value_json['ENERGY']['Yesterday']}}"} (retained) 21:29:19 MQT: homeassistant/sensor/7BC667_ENERGY_Today/config = {"name":"Extra 1 ENERGY Today","stat_t":"tele/extra1/SENSOR","avty_t":"tele/extra1/LWT","pl_avail":"Online","pl_not_avail":"Offline","uniq_id":"7BC667_ENERGY_Today","dev":{"ids":["7BC667"]},"unit_of_meas":"kWh","dev_cla":"power","frc_upd":true,"val_tpl":"{{value_json['ENERGY']['Today']}}"} (retained) 21:29:19 MQT: homeassistant/sensor/7BC667_ENERGY_Power/config = {"name":"Extra 1 ENERGY Power","stat_t":"tele/extra1/SENSOR","avty_t":"tele/extra1/LWT","pl_avail":"Online","pl_not_avail":"Offline","uniq_id":"7BC667_ENERGY_Power","dev":{"ids":["7BC667"]},"unit_of_meas":"W","dev_cla":"power","frc_upd":true,"val_tpl":"{{value_json['ENERGY']['Power']}}"} (retained) 21:29:20 MQT: homeassistant/sensor/7BC667_ENERGY_ApparentPower/config = {"name":"Extra 1 ENERGY ApparentPower","stat_t":"tele/extra1/SENSOR","avty_t":"tele/extra1/LWT","pl_avail":"Online","pl_not_avail":"Offline","uniq_id":"7BC667_ENERGY_ApparentPower","dev":{"ids":["7BC667"]},"unit_of_meas":"VA","dev_cla":"power","frc_upd":true,"val_tpl":"{{value_json['ENERGY']['ApparentPower']}}"} (retained) 21:29:20 MQT: homeassistant/sensor/7BC667_ENERGY_ReactivePower/config = {"name":"Extra 1 ENERGY ReactivePower","stat_t":"tele/extra1/SENSOR","avty_t":"tele/extra1/LWT","pl_avail":"Online","pl_not_avail":"Offline","uniq_id":"7BC667_ENERGY_ReactivePower","dev":{"ids":["7BC667"]},"unit_of_meas":"VAr","dev_cla":"power","frc_upd":true,"val_tpl":"{{value_json['ENERGY']['ReactivePower']}}"} (retained) 21:29:20 MQT: homeassistant/sensor/7BC667_ENERGY_Factor/config = {"name":"Extra 1 ENERGY Factor","stat_t":"tele/extra1/SENSOR","avty_t":"tele/extra1/LWT","pl_avail":"Online","pl_not_avail":"Offline","uniq_id":"7BC667_ENERGY_Factor","dev":{"ids":["7BC667"]},"unit_of_meas":"Cos φ","ic":"mdi:alpha-f-circle-outline","frc_upd":true,"val_tpl":"{{value_json['ENERGY']['Factor']}}"} (retained) 21:29:20 MQT: homeassistant/sensor/7BC667_ENERGY_Voltage/config = {"name":"Extra 1 ENERGY Voltage","stat_t":"tele/extra1/SENSOR","avty_t":"tele/extra1/LWT","pl_avail":"Online","pl_not_avail":"Offline","uniq_id":"7BC667_ENERGY_Voltage","dev":{"ids":["7BC667"]},"unit_of_meas":"V","ic":"mdi:alpha-v-circle-outline","frc_upd":true,"val_tpl":"{{value_json['ENERGY']['Voltage']}}"} (retained) 21:29:20 MQT: homeassistant/sensor/7BC667_ENERGY_Current/config = {"name":"Extra 1 ENERGY Current","stat_t":"tele/extra1/SENSOR","avty_t":"tele/extra1/LWT","pl_avail":"Online","pl_not_avail":"Offline","uniq_id":"7BC667_ENERGY_Current","dev":{"ids":["7BC667"]},"unit_of_meas":"A","ic":"mdi:alpha-a-circle-outline","frc_upd":true,"val_tpl":"{{value_json['ENERGY']['Current']}}"} (retained) 21:29:20 MQT: homeassistant/sensor/7BC667_status/config = {"name":"ZooZee status","stat_t":"tele/extra1/HASS_STATE","avty_t":"tele/extra1/LWT","pl_avail":"Online","pl_not_avail":"Offline","json_attr_t":"tele/extra1/HASS_STATE","unit_of_meas":"%","val_tpl":"{{value_json['RSSI']}}","ic":"mdi:information-outline","uniq_id":"7BC667_status","dev":{"ids":["7BC667"],"name":"ZooZee","mdl":"ZooZee","sw":"8.2.0.5(2e725b7-tasmota)","mf":"Tasmota"}} (retained)



### TO REPRODUCE
1. Upgrade firmware to latest version available on http://thehackbox.org/tasmota/ or any archived binary after `20200421-120032-1065381-tasmota.bin`.
2. On the "Configure Other" screen, Set "Friendly Name 1" to something meaningful; ex. Test 1
3. Ensure HA autodiscover mode is on (`SetOption19 1`)
4. Ensure mqtt is set up to allow communication between Tasmota and HomeAssistant
5. Navigate another Web browser tab / window to your HomeAssistant interface
6. In HA: Click Configuration - Devices to get a list of all the devices presently in HA

### EXPECTED BEHAVIOUR
The Tasmota device should be listed in HA Device list using its Friendly Name 1 value which defaults to "Tasmota", and in our above example, should be "Test 1"

### OBSERVED BEHAVIOUR
The Tasmota device is listed in HA Device list using its Model Name; which is the Template Name, when in the Module config. Incidentally, changing this value _does_ correct the name seen in HA, but it also changes the type of device to be the same as that name. Ie: instead of "Sonoff Basic", the model would be "Test 1".

### SCREENSHOTS
<img width="422" alt="Screen Shot 2020-04-29 at 2 51 00 PM" src="https://user-images.githubusercontent.com/219596/80645855-f4497080-8a28-11ea-8c8c-9e74351f5f04.png">
<img width="1306" alt="Screen Shot 2020-04-29 at 2 45 57 PM" src="https://user-images.githubusercontent.com/219596/80645710-bb110080-8a28-11ea-9630-daab7065630a.png">
<img width="364" alt="Screen Shot 2020-04-29 at 2 46 34 PM" src="https://user-images.githubusercontent.com/219596/80645725-c06e4b00-8a28-11ea-8abe-01a041594052.png">

### ADDITIONAL CONTEXT
_Add any other context about the problem here._

**(Please, remember to close the issue when the problem has been addressed)**
blakadder commented 4 years ago

This is the designed behaviour for next stable release.

effelle commented 4 years ago

And will be extended on sensors name too as soon as I'll finish the new light management.

potto007 commented 4 years ago

I guess I'll ask about something like this in chat next time, first. Lesson learned.

effelle commented 4 years ago

no problem at all, I thank you for the effort and the time you spent for it.

Jibun-no-Kage commented 2 years ago

How do you query for the friendly name using MQTT only? is there a cmnd subscriber on TASMOTA that will return INFO1,2, etc. on demand?

I have been watching my MQTT broker and reviewing the message logging and other than initial power up of TASMOTA firmware INFO1,2, etc. never happens? No way to trigger it, thus no easy way to get the friendly name?

barbudor commented 2 years ago

What about sending the 'FriendlyName' command to Tasmota and get the result?

sfromis commented 2 years ago

In addition to the directly applicable command, the "friendly names" are also included in the output of the Status command, and in the tasmota/discovery/<mac>/config message published to MQTT when connecting - not in INFO1/2/3.