Ok this revives and old one.
from the distant past
I am in sort of the same situation. . My publish command is on an automation going every 2 minutes.
action: mqtt.publish
data:
evaluate_payload: true
qos: "2"
retain: false
topic: owntracks/jason/iphone/jh/steps
payload: "'{\"_type\" : \"cmd\", \"action\": \"reportSteps\"}'"
my MQTT Sensor defined in configuration.yaml is
mqtt:
sensor:
- state_topic: "owntracks/jason/iphone/jh/steps"
name: "Steps Jason"
# unit_of_measure: "m"
value_template: '{{ value_json.steps }}'
- state_topic: "owntracks/jason/iphone/jh/steps"
name: "Distance Jason"
unit_of_measurement: "m"
value_template: '{{ value_json.distance | round(1) }}'
with MQTT Explorer I can see the MQTT Publish is working, and the following message is being received by the broker
025-9-8 0:44:0.289 topic: owntracks/jason/iphone/jh/cmd
QoS 2
'{"_type" : "cmd", "action": "reportSteps"}'
the sensor’s value does not change. I assumed that the message just has place holder or I am not processing it right to update the sensor
So far over my head. but I am giving it a try
Ok. I have been working at this with out the desired success
I tweaked the definition of the sensor to as follows
mqtt:
sensor:
- state_topic: "owntracks/jason/iphone/steps"
name: "Steps Jason"
# unit_of_measure: "m"
value_template: '{{ value_json.steps }}'
- state_topic: "owntracks/jason/iphone/steps"
name: "Distance Jason"
unit_of_measurement: "m"
value_template: '{{ value_json.distance | round(1) }}'
I dont know if this is pertinent but my device tracker configuration is
device_tracker:
- platform: owntracks
max_gps_accuracy: 100
waypoints: true
mqtt_topic: "owntracks/#"
events_only: false
waypoint_whitelist:
jason
jh
captcurrent
joh
the automation publishing this info is
action: mqtt.publish
data:
evaluate_payload: true
qos: "2"
retain: false
topic: owntracks/jason/iphone/steps
payload: "'{\"_type\" : \"cmd\", \"action\": \"reportSteps\"}'"
Using MQTT Explorer I can see thay the publication is work every 2 minutes.
Using a test client I see this is message being sent
2025-9-9 17:45:36.348 topic: owntracks/jason/iphone/steps
QoS 2
'{"_type" : "cmd", "action": "reportSteps"}'
The sensor does not change value. .
I made sure the phone was awake
It would appear that the message is empty or can’t be read so nothing to update the sensor. I guess