and I indeed now see a sensor.zigbee with the value of the last MQTT message from Zigbee2MQTT. The problem is that I do not know what topic it relates to.
Would there be a smart way to create such a sensor and avoid making one entry per device (topic)?
Thank you for the idea. When you mention “drop”, what would the actual action be? (I understand the templating part (I think), it is more how to actually create (then update) a sensor I do not know)
- id: '1606228580226'
mode: queued
max: 10
alias: Zigbee2MQTT events
description: ''
trigger:
- platform: mqtt
topic: zigbee2mqtt/+
condition: []
action:
# here comes the action to extract trigger.topic and trigger.payload and combne them into the sensor ← this is what I do not understand how to do
drop, I mean set the text of the input_text to the trigger data. You’re not going to be using a sensor. If you want to use a sensor, you’ll have to use one of the many back door methods to get the information into the sensor.
if you want to see what topics are sent and received to/from your broker, the easiest tool is something like Mqtt explorer. it lists all of your registered subscribers and all of the sent topics with their values.
A simple copy and past will then give you the topic for the mqtt sensor in HA.
afraid I wouldn’t really now of a way to circumvent the 255 char limit of the sensor, and set the mqtt payload as attribute for that sensor (the backdoor Petro refers to). Same would go for a notification file platform I fear, which is what I use to record larger sets of data.
The problem is that I use the wall switches to automate some lights and I want to keep the zigbee id ← → action in the automation (via pyscript). So I need to know which topic sent which topic sent which payload.
In that case, you’re halfway there. The automation you posted (above) subscribes to all ZigBee2MQTT topics. All that’s left is to create an action that publishes the received topic and payload to an MQTT Sensor’s topic.
I’d be very interested in what you would come up with to create the listing of topics and events/payloads you are looking for. Could you keep us posted on that?
I am currently rethinking my automations. I use AppDaemon but I am considering moving to pyscript. When this actually happens I may do one of two things:
use an automation in HA to send my MQTT data to a @service there (this is what is pointed to by the answers in this thread)
or connect to MQTT directly from pyscript (via paho)
I would prefer the first option if I was able to have a sensor for my data. I have one for RF433 signals (I go though a Sonoff RF Bridge that posts everything to one topic). But if I cannot have the same for Ziggbee2MQTT then I will probably go for the second solution and centralize the wall switch management there. Any maybe update a state in HA from there (to have a feedback/history in HA)