1technophile / OpenMQTTGateway

MQTT gateway for ESP8266 or ESP32 with bidirectional 433mhz/315mhz/868mhz, Infrared communications, BLE, Bluetooth, beacons detection, mi flora, mi jia, LYWSD02, LYWSD03MMC, Mi Scale, TPMS, BBQ thermometer compatibility & LoRa.
https://docs.openmqttgateway.com
GNU General Public License v3.0
3.56k stars 786 forks source link

Home Assistant Warning: "Template variable warning: 'dict object' has no attribute 'displaymetric' when rendering '{{ value_json.displaymetric }}' #1681

Closed Snuffy2 closed 1 year ago

Snuffy2 commented 1 year ago

Describe the bug Since upgrading to v1.6.0, I've been getting a lot of these errors in my Home Assistant logs.

2023-06-11 21:33:44.109 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'displaymetric' when rendering '{{ value_json.displaymetric }}'

SNAG-1946

I believe it is coming from OMG and may be related to #1504 although I believe that was added in v1.5.0 and seems to be this line

I'm running a Heltec WiFi LoRa 32 (V2.1) running RTL_433 which I believe uses the SSD1306 Display. I do have the display turned off.

SNAG-1945

I do not recall seeing these errors in Home Assistant with OMG v1.5.1

Environment (please complete the following information):

Snuffy2 commented 1 year ago

I turned on the Display to see if that had any effect and it didn't seem to change anything. The error is still appearing. Another thing I noticed is that displayMetric is not listed as an item in the SSD1306toMQTT JSON when looking with MQTT Explorer. It is listed under WebUItoMQTT and changes when I check/uncheck the Display Metric box in the WebUI.

2023-06-13_20-44-17 645
DigiH commented 1 year ago

This looks like a legacy discovery for displaymetric for SSD1306, from before it was moved to the WebUI. Needs to be removed for SSD1306/moved to WebUI.

DigiH commented 1 year ago

Hi @Snuffy2

would you be able to verify with a test build?

DigiH commented 1 year ago

@Snuffy2

A test build which should fix the warning messages can be installed at

https://docs.openmqttgateway.com/dev/upload/web-install.html

If you could also check the correct switching between metric and imperial units, that would be great.

Snuffy2 commented 1 year ago

I installed version 9d8a96 this evening.

DigiH commented 1 year ago

Thanks for testing @Snuffy2

The displayMetric setting only applies to the alternating device property unit display on the WebUI main page and on the Heltec/LilyGo internal OLED display.

The rtl_433 published MQTT messages will always have temperature_C, which can/should be auto converted to Fahrenheit if so defined in HA.

I was more curious as to whether the switching also works now in the HomeAssistant Gateway Control for the different display on the Heltec and WebUI.

Snuffy2 commented 1 year ago

Gotcha. The temperature does show correctly in °F in the WebUI when I uncheck Display Metric.

DigiH commented 1 year ago

Thanks for the confirmations.

Closing