As per subject, how to I initialise an MQTT published topic.
I’m using generic_thermostat component and when I start HA, I have the initial values set but these are not copied to the related MQTT topic. When I change the setpoint value on the front end, for the thermostat, the values do get copied to the MQTT topic. So all good, except at start up.
This is the automation on the generic_thermostat, that works, but it does not fire at start up .
automation:
- alias: Thermostat setpoint to TRV
initial_state: true
#hide_entity: true
trigger:
platform: state
entity_id: climate.therm
attribute: temperature
action:
service: mqtt.publish
data_template:
topic: '/energenie/eTRV/Command/Temperature/8005'
retain: true
payload: "{{ state_attr('climate.therm','temperature') | int }}"
and the MQTT
sensor:
- platform: mqtt
state_topic: "/energenie/eTRV/Report/Temperature/8005"
name: "TRV 8005 Temperature"
device_class: temperature
unit_of_measurement: "°C"
force_update: true
expire_after: 660
Not sure if force_update is right, it doesnt seem to make any difference?
Perhaps there is a better way of setting values for startup so that they get sent to the mqtt topic?