@123 Thank you for your demultiplexer insight. @VDRainer approach is the one that I was using so far. Now, I am testing yours, and need advice on how to create a condition in the automation.
Using the demultiplexer approach…
- id: '1234567890123'
alias: OpenMQTTGateway demultiplexer
description: ''
trigger:
- platform: mqtt
topic: home/OpenMQTTGateway/PilighttoMQTT
action:
- data_template:
payload: '{{trigger.payload}}'
topic: '{{ ''home/sensor'' + trigger.payload_json.message.channel|string }}'
service: mqtt.publish
new topics are created as eg.
home/sensor3 {"message":{"id":145,"temperature":26.10,"humidity":10.00,"battery":1,"channel":3},"protocol":"tfa","length":"145","repeats":2,"status":2}
home/sensor {"message":{"id":153.0,"temperature":52.8,"humidity":40.0,"battery":0.0},"protocol":"teknihall","length":"153","repeats":2,"status":2}
home/sensor2 {"message":{"id":174,"temperature":25.70,"humidity":74.00,"battery":1,"channel":2},"protocol":"tfa","length":"174","repeats":2,"status":2}
home/sensor {"message":{"id":154.0,"temperature":27.2,"humidity":10.0,"battery":1.0},"protocol":"teknihall","length":"154","repeats":2,"status":2}
home/sensor1 {"message":{"id":88,"temperature":27.60,"humidity":75.00,"battery":1,"channel":1},"protocol":"tfa","length":"88","repeats":2,"status":2}
home/sensor {"message":{"id":149.0,"temperature":1.7,"humidity":34.0,"battery":1.0},"protocol":"teknihall","length":"149","repeats":2,"status":2}
This way there is no need to update the automation.yaml script everytime id value changes. Topics home/sensor1 home/sensor2 home/sensor3 are the sensors I am interesed in. However, messages that do not have a channel value result in the creation of an unneeded topic home/sensor
I am interested only in “protocol”:“tfa” readings (my devices are listed under that protocol and all have a channel value) but a condition such as:
condition:
- condition: template
value_template: "{{ value_json.protocol == 'tfa' }}"
results in no messages posted for the different demultiplexed sensors under their respective topics home/sensor1 home/sensor2 home/sensor3
Suggestions are welcome and appreciated in advance.