Hi everyone.
I’m trying to integrate the various functions that the zigbee remote control has, and I’m stuck on some things.
The device in question is: https://www.zigbee2mqtt.io/devices/MLI-404011.html integratet with Zigbee2Mqtt, and works correctly.
Now I would like to extract the xy attributes that I receive when I press, to be able to use it on the action of an automation.
Actually, with the help of a friend @Alesoft73 i did it, and it works fine. But the problem is that every time I get an error on the log. Here’s what we did.
- alias: Tint Colori Led TV
mode: parallel
trigger:
- platform: state
entity_id: sensor.tint_action
to: 'color_wheel'
action:
- service: light.turn_on
data_template:
entity_id: light.led_tv
xy_color: >
[{{ state_attr("sensor.tint_action","action_color") | regex_replace("([xy:{}\-\/@])")| regex_replace("'") | replace (" ","")}}]
Error while executing automation automation.tint_colori_led_tv: None for dictionary value @ data['xy_color']
Tint Colori Led TV: Error executing script. Invalid data for call_service at pos 1: None for dictionary value @ data['xy_color']
Where is that result coming from? What’s making that entity? That looks like a dictionary but it’s not because the comma is missing, meaning that’s a string response with carriage returns. This seems like a bug in whatever is creating that entity. So, if you created the MQTT topic for that information, you forgot the comma. Once you add that in, these should work:
It is an integrated remote control on Zigbee2Mqtt, https://www.zigbee2mqtt.io/devices/MLI-404011.html which exposes me in Home Assistant via autodiscovery.
I show you the results i receive on the Z2M log and on the sensor in HA.
Z2M log:
I meant ‘what’s creating the entity’. It seems like it’s MQTT, but that’s a guess because MQTT discovery would have formatted it properly. My guess is that he manually configured the MQTT device.
Yes, but the data getting sent from zigbee2mqtt to HA is what you want to look at. So what does the topic contain when zigbee2mqtt writes to the topic from the device?
The problem I have is that your published data appears to be correct but the output from sensor.tint_action is not valid.
I would have debugged the mqtt topic by subscribing to zigbee2mqtt/Tint but fear that will be valid so my hunch is firmly in the way that sensor.tint_action is being populated or modified.
Something has been lost in translation whilst populating that sensor. Do you have the definition for this sensor that you can provide - maybe in configuration.yaml or is it automatically created ?
Considering I’ve also found this post it may be a good time to post all the related sensors and configuration and explain exactly what you’re trying to achieve rather than trying to solving the problem piecemeal which can lead to further problems down the road
The sensor is populated automatically, with Z2m autodiscovery.
The json in zigbee2mqtt is correct {“x”: 0.118, “y”: 0.197}.
Instead in home asssitant it is imported incorrectly.
You can see it from how you set Entity from Home Assistant.
So for now the only way to fix and have no errors is to filter and split the entity.
So: