posted in a GitHub issue before before, but that now is closed, so please bear with me here in this dedicated topic for an mqtt publish service, I simply can’t get workin in Ha 117.0b5
@BrianHanifin hope you don’t mind the tag, but since we we’re both in the issue tracker, supposed you would still be struggling with the same…
here’s the original mqtt service I used successfully up to 117:
action:
service: mqtt.publish
data:
topic: location/marijn
retain: true
payload: >-
{
"latitude": "{{state_attr('zone.home','latitude')}}",
"longitude": "{{state_attr('zone.home','longitude')}}",
"battery_level": {{states('sensor.calltheboss_battery_level')|int}},
"gps_accuracy": 0
}
and
action:
service: mqtt.publish
data:
topic: location/marijn
retain: true
payload: >-
{
"latitude": "{{trigger.to_state.attributes.latitude}}",
"longitude": "{{trigger.to_state.attributes.longitude}}",
"battery_level": {{states('sensor.calltheboss_battery_level')|int}},
"gps_accuracy": {{trigger.to_state.attributes.gps_accuracy|int}}
}
note this is a carefully built payload, and the quotings are correct. See here for explanation
error:
Marijn Presence Update from Router or Bluetooth: Error executing script. Unexpected error for call_service at pos 1: payload must be a string, bytearray, int, float or None.
While executing automation automation.marijn_presence_update_from_router_or_bluetooth
.....
TypeError: payload must be a string, bytearray, int, float or None.
I’d need this exact payload, so something like this doesn’t work (I’ve tried)
action:
service: mqtt.publish
data:
topic: location/marijn
retain: true
payload:
latitude: "{{state_attr('zone.home','latitude')}}",
longitude: "{{state_attr('zone.home','longitude')}}",
battery_level: {{states('sensor.calltheboss_battery_level')|int}},
gps_accuracy: 0
hope anyone can get this to work, it seems a rather basic mqtt payload, so hope this helps the community too…
must add this is for the device_tracker mqtt_json:
device_tracker:
- platform: mqtt_json
devices:
marijn_presence: location/marijn
so maybe that’s causing the issue? A json tracker not getting json anymore …?