Hello,
I am trying to integrate my Nissan Leaf position as provided to MQTT by the OVMS device in it.
What I have is the latitude and longitude of it written in two sensors.
This is what I am trying to do:
Sensors for coordinates extracted from MQTT by my Leaf OVMS:
- platform: mqtt
name: leaf position lat
state_topic: "ovms/nissanleaf/xxx/metric/v/p/latitude"
qos: 1
- platform: mqtt
name: leaf position lon
state_topic: "ovms/nissanleaf/xxx/metric/v/p/longitude"
qos: 1
Automation to update the position/create the tracker:
This is actually triggered (I’ve checked) but no tracker is ever created or updated. I created the tracker manually by triggering the method (without gps data) and it works. But as soon as I try to use templates to insert either gps data or battery level it complains about the data_template not being a valid keyword or that I am missing dev_id (depending on how I build up the yaml).
Edit: I just realized you have data and then data_template. You only need one. If you run 0.115 or higher remove the data_template otherwise remove data
Oh, more: if I actually make the call with hard-coded data in the right format ( [xx.xxx,yy.yyy]) the update is done just fine.
It seems that templating is the issue, I cannot find a format it will accept.
Tried with conversion to float, tried inline like suggested by @Hellis81, none worked.
I still get errors either it’s not finding the dev_id or not accepting the value for gps (invalid latitude for dictionary value).
@Hellis81 I know it will trigger often (configurable on OVMS) but that’s the same as any other device tracker using gps like phone or such.
I managed to get it! Problem was I was using the automation editor, it does not want you to put “data:” in the field (it’s implicit, apparently). @burningstone 's reply gave me the right hint! So this is what I used and worked:
@anon43302295, I don’t want to start a polemic thread but I did numerous tries and trust me, the problem was I was adding “data” in the “service data” field of the editor.
I tried to simplify the problem in the description to try to avoid confusion but I spent a whole day yesterday before coming here.
The capital letter is entirely disregarded (works either way), source_type is not mandatory (but I did test with it) and the data_template was indeed in some of my tests but not all of them.
What sorted it was sticking to the editor instead of mixing editor/direct calls/files and filling the right data.
But indeed thank you for answering and the support.
I’m just trying to say that if you came here for help, I provided you with the exact code you needed in the second reply to this thread, all you needed to do was copy and paste it into your automation and you would have been sorted.
Every extra struggle you’ve had from that moment on was unnecessary.
Hi Andy,
I have been trying to replicate your solution to device tracking. I am receiving the gps co-ordinates and the automation is being triggered when gps co-ordinates are received. However I cannot find the device anywhere (dev-id: Leaf in your case). Where is this set up or is the automation supposed to create it when triggered?
Now I don’t remember if I did other stuff, but one of the alternatives I tested was calling the device_tracker.see manually in the developer’s tools.
What is the code you’re using?
Hi Andy,
Thanks to you, I am a little more further due to the fact that I had not set up mac, host name and gps accuracy.
I have called the device_tracker.see service by inserting the mac as well. I can now see the entity and mac but no plot on the map yet. Look forward to any suggestions.