HI,
would it be possible to move the mqtt state_topic to the !secrets file? I’ve tried various lines, but no succes yet…
- platform: mqtt
state_topic: ‘owntracks/id/phonename’
name: “Owntracks batt”
value_template: ‘{{value_json.batt}}’
state_topic: !secret mqtt_topic
doesn’t work, neither do state_topic: !secret 'mqtt_topic'
nor state_topic: '!secret mqtt_topic'
for obvious reasons…
Could it be done?
thanks,
Marius
In what way doesn’t it work?
All !secret does is replace the line with the corresponding one from your secrets file.
what i mean is the definition of the full sensor is wrong with the way i used !secret above.
What i would like is to have the real state_topic only in my secrets file, and use the secret construction for all sensors in the configuration files for the sensors.
like this:
rc_audio_auditorium_on:
url: !secret rest_command_url
method: POST
payload: '{"seq":1, "method":"object_prop_set", "arguments":{"oid":"0e56e15c", "prop":"command", "value":"on"}}'
So I’m looking for a way to replace the 2nd line of these sensors. (or only the state_topic bit) Im certain if it’s even possible .
i would have hoped this worked:
- platform: mqtt
state_topic: !secret owntracks_mqtt_topic
name: "Owntracks batt"
value_template: '{{value_json.batt}}'
and it does
forgot the mqtt_topic’s are case sensitive and made a typo in the secret… uhh
so easy to share this now, and ask you how to create a Home-sensing device of that. I don’t have a device in the known_devices that does it automatically as it apparently would have done had i use the owntracks_http component:
- platform: mqtt
state_topic: !secret owntracks_mqtt_topic
name: "Owntracks Lon"
value_template: '{{value_json.lon}}'
- platform: mqtt
state_topic: !secret owntracks_mqtt_topic
name: "Owntracks Lat"
value_template: '{{value_json.lat}}'
I would use _http if I could use the Secret in Owntracks, but since that won’t work yet, id rather not…
got it working!.. wasn’t an error in the sensor syntax, but in the secrets. had ’ ’ around the secret, which wasn’t as it should be.
By accident I discovered that the device_tracker (either of the 2) and the mqtt sensor are entirely independent… I had an internal server error, commented out the device_tracker (thought it caused the error), and my Owntracks sensors still where there.![:wink: :wink:](https://community.home-assistant.io/images/emoji/twitter/wink.png?v=12)
After some heavy experimenting on the device_tracker, it kept saying i couldn’t parse the mqtt-topic, i decided to give it a last shot without the mqtt_topic. Et voila, there it was. a nicely reporting known_device, showing Home and Away. ![:+1: :+1:](https://community.home-assistant.io/images/emoji/twitter/+1.png?v=12)
use this now in device_tracker.yaml:
- platform: owntracks
max_gps_accuracy: 100
# secret: !secret owntracks_secret
waypoints: true
# mqtt_topic: !secret owntracks_mqtt_topic
waypoint_whitelist:
- !secret owntracks_user_id
kinda cool. Cant have the locations show up in Hassio yet, even with explicitly queuing the location, but a big leap was made.
Thanks for your assistance in clearing my mind in this configuration!
Marius
1 Like