Hi,
Use a quick one.
Is it possible to use sring constants and concatenation within the State_topic of a MQTT template.?
The reason that I ask is that for my MQTT template the core part of the State_topic is the same for each entity.
I have tried using ‘input_text’ for this and I get the correct text when using the ‘Developer tools template’, but when I try and use the same structuture within the MQTT template I get a returned value of ‘unknown’.
In my configuation file I have
input_text:
ihd_state:
name: IHD State
initial: "glowaintree/84CCA8544CC4/"
In the developer tool template I use:
{{states('input_text.ihd_state')}}SENSOR/electricitymeter
giving me the correct value of:
glowaintree/84CCA8544CC4/SENSOR/electricitymeter
when I encorporate this in the MQTT template as:
sensor:
- name: "Smart Meter test"
unique_id: "smart_meter_test"
state_topic: "{{states('input_text.ihd_state')}}/SENSOR/electricitymeter"
device_class: "energy"
unit_of_measurement: "kWh"
state_class: "total_increasing"
value_template: "{{ value_json['electricitymeter']['energy']['export']['cumulative'] }}"
icon: "mdi:flash"
The unique ID returns unknown.
Thanks for any help tthat you can give me.
Graham.