sblantipodi / firefly_luciferin

Very fast Java screen capture PC software designed for the Glow Worm Luciferin firmware, the combination of these software create the perfect Bias Lighting and Ambient Light system for PC.
GNU General Public License v3.0
312 stars 29 forks source link

[Bug]: Home Assistant error caused by undefined LDR values #111

Closed bcameron21 closed 1 year ago

bcameron21 commented 1 year ago

Firefly Luciferin version

2.10.10

Glow Worm Luciferin version

5.9.7

Firmware type

FULL

What is the stream method?

MQTT Stream

Fiefly Luciferin config file

No response

Relevant log output

No response

How to reproduce

My error logs are filled with warnings:

Template variable warning: 'dict object' has no attribute 'ldr' when rendering '{{ value_json.ldr }}'

I don't have a light density resistor installed or active. It seems that the Esp devices is passing a setting, but Home Assistant doesn't know what to do with it.

In Home Assistant it is picking up a Luciferin LDR entity from MQTT, with a value "Unknown".

Using MQTTExplorer I can see a config paramter being passed in the topic luciferin/ldr/config with the follwing value template:

{ "name": "Luciferin LDR", "icon": "mdi:theme-light-dark", "unique_id": "Luciferin_LDR", "state_topic": "lights/glowwormluciferin", "value_template": "{{ value_json.ldr }}", "unit_of_measurement": "%" }

sblantipodi commented 1 year ago

hi @bcameron21, did you enabled the HA integration?

https://github.com/sblantipodi/firefly_luciferin/wiki/Home-Automation-configs

bcameron21 commented 1 year ago

Good point. Rereading that link, as well as a conversation on Discord I realised that I was using the package version of the integration. Removed that from HA, and let Luciferin set itself up with MQTT autodiscovery.

After this I was still getting the error in the logs.

Using MQTT Explorer I deleted the retained config message mentioned above, and that stops the error message.

However if I reset the config by clicking on the tick next to the MQTT discovery topic in the Luciferin settings, then that adds it back to MQTT. This also recreates the entity in HA (i.e. sensor.luciferin_ldr). And the errors start again!

The workaround I'm going with for now is to delete the MQTT retained message.

Not sure how else to investigate this further.

sblantipodi commented 1 year ago

Hi @bcameron21, ok I identified the problem and fixed it.

You have found a workaround already, next release is going to fix the problem once and for all :)

Thank you for reporting it, this is much appreciated!!!