#Tinkerer, following on about the PSA Car
1 messages ยท Page 1 of 1 (latest)
What do you mean "variables"?
Nothing in https://github.com/Flodu31/HomeAssistant-PeugeotIntegration#configuration mentions a location
In the PSA Car Controller it pulls the car last location, i can see in the plugin where the car is right now, so it seems to have that information. I just need to create a connection between them
What do you mean plugin?
Do you mean the add-on?
If yes, whenever you respond, then you need to check if the API provides that location
resource: http://IPofTheSoftware:5000/get_vehicleinfo/YourVIN?from_cache=1
If that doesn't show it then there's nothing you can do
The Add-On PSA Car Controller (plugin) provides on a map where the car is
That's not a plugin
There's no such thing as plugins
They're called add-ons
Yes, the words you use matter ๐
Okay so now we've confirmed i'm taking about the add-on and not plugin, is there a way?
That PSA aside: #1248578514962219139 message
I need to find out how it descripes that geo-location and then i can (assumably) create a sensor for it?
Yes, though it's not going to be trivial
First you need to get the data
Then you'll have to create a dummy device_tracker and use the device_tracker.see service or create an MQTT device tracker and publish the location to MQTT
If i look back at the github i should be able to go into the PSA Car Controller and find the location call and what its assigned too?
I can see a last_position sensor in there
And does that have a lat and long, or a word, or...?
Then you'll have to create a dummy
device_trackerand use thedevice_tracker.seeservice or create an MQTT device tracker and publish the location to MQTT
Okay i'll go look it up and see what i can do
- service: device_tracker.see
data:
dev_id: "car_gps"
gps_accuracy: "10"
gps:
- "{{ latitude template }}"
- "{{ longitude template }}"
Having created car_gps in known_devices.yaml and restarted HA
car_gps:
icon:
mac:
name: car gps
picture:
track: true
Won't it need to call the information from the url?
device_tracker:
name: corsa_e
resource: http://censored:5000/get_vehicleinfo/censor?from_cache=1
"last_position": {"type": "Feature", "geometry": {"coordinates": [-1.21465, 54.55443, 29.0], "type": "Point"}
Ok... you need a sensor with the lat and long
Then you need the service call above and a #templates-archived to pull the lat and long
There is no restful device trackerr
So, baby steps
First you need to get the data
Do that
Okay so if i stick this in the sensors.yaml
name: corsa_e
resource: http://censor:5000/get_vehicleinfo/censored?from_cache=1
scan_interval: 60
timeout: 30
value_template: 'OK'
json_attributes:
-last_position
- platform: template
sensors:
corsa_e_latitude:
friendly_name: "Latitude"
value_template: '["last.position"]["geometry"]["coordinates"]["0"]'
sensors:
corsa_e_longitude:
friendly_name: "Longitude"
value_template: '["last.position"]["geometry"]["coordinates"]["1"]'```
That hopefully will get the data from the json
then i can use the corsa_e_latitude in place like this
data:
dev_id: "car_gps"
gps_accuracy: "10"
gps:
- "corsa_e_latitude"
- "corsa_e_longitude"```
Would that work?
No
First, you need actual templates in the service call
Second, you've mashed a template sensor and rest sensor together without understanding what's going on
Completely agree i'm still learning how to do this
but i think i'm starting to understand how it work (a little)
- platform: template
sensors:
corsa_e_latitude:
friendly_name: "Corsa E Lat"
value_template: '{{ states.sensor.corsa_e.attributes["last.position"]["geometry"]["coordinates"]["0"] }}'
corsa_e_longitude:
friendly_name: "Corsa A Long"
value_template: '{{ states.sensor.corsa_e.attributes["last.position"]["geometry"]["coordinates"]["1"] }}'
(probably)
Then
- service: device_tracker.see
data:
dev_id: "car_gps"
gps_accuracy: "10"
gps:
- "{{ states('sensor.corsa_e_latitude') }}"
- "{{ states('sensor.corsa_e_longitude') }}"
(probably)
#templates-archived can help you with templates if you get stuck
Remember that last piece is a service call that doesn't go in the sensor definition
Okay, great help me understand this... how does HA know where to find the last.position, do it just know that because its been called from else where in the yaml
You'll use that service in an automation that's called when the lat/long changes
Hopefully it's in the JSON
You may have to add last.position to the JSON attributes
You can also massively improve what's in https://github.com/Flodu31/HomeAssistant-PeugeotIntegration#configuration by moving to https://www.home-assistant.io/integrations/rest
Just restarted HA after adding the sensor but its showing as status Unavaliable
Go back and do all the troubleshooting steps again
Got it pulling the information now, templates channel helped me. Thanks again for all the help
I'm trying to add - service: device_tracker.see data: dev_id: "car_gps" gps_accuracy: "10" gps: - "{{ states('sensor.corsa_e_latitude') }}" - "{{ states('sensor.corsa_e_longitude') }}" to a yaml file but its asking for a platform
Remember that last piece is a service call that doesn't go in the sensor definition
You'll use that service in an automation that's called when the lat/long changes
(from above)
Also see #1248578514962219139 message
I've created the known_devices.yaml, do i need to reference that in the configuration.yaml?
I'm creating the automation now...
When corsa e lat or corsa e long changes state or any attributes as the 'When'
Then do ' Call a service 'Device Tracker: See'
Manually ran the automation and got this error must contain at least one of mac, dev_id
Sadly we're not mind readers (any more anyway, not after the last time we tried). Please share the YAML and any errors so we can see what you've done.
description: ""
trigger:
- platform: state
entity_id:
- binary_sensor.corsa_e_lat
- binary_sensor.corsa_e_long
condition: []
action:
- service: device_tracker.see
data: {}
mode: single```
Its my first time creating a automation (hell its my first time for a lot of things today)
Did you look at that before posting it?
Did you compare the service call to what I posted? Hell, to what you posted?
I used the visual builder when i did, maybe i should stick to the yaml file and i might have seen something
- service: device_tracker.see
data: {}
vs
- service: device_tracker.see
data:
dev_id: "car_gps"
gps_accuracy: "10"
gps:
- "{{ states('sensor.corsa_e_latitude') }}"
- "{{ states('sensor.corsa_e_longitude') }}"
Okay, lets go back to me being an idoit here as I don't understand. I created the known_devices.yaml and put the - service: device_tracker.see data: dev_id: "car_gps" gps_accuracy: "10" gps: - "{{ states('sensor.corsa_e_latitude') }}" - "{{ states('sensor.corsa_e_longitude') }}" code into it
Having created car_gps in known_devices.yaml and restarted HA
car_gps:
icon:
mac:
name: car gps
picture:
track: true
This section
car_gps:
icon:
mac:
name: car gps
picture:
track: true
Ah so you meant the top part in the known_devices not the bottom part
's fine
Just ... start paying attention when the error appears
When that happens, look at what I wrote, and what you have
Okay so... i don't get this wrong and look even worse... i've gone into the automation (yaml editor) should i just copy and paste what you have or does it need the tigger part as well. Like this ```alias: Corsa E GPS Change
description: ""
trigger:
- platform: state
entity_id:- binary_sensor.corsa_e_lat
- binary_sensor.corsa_e_long
condition: []
action:
- service: device_tracker.see
data:
dev_id: "car_gps"
gps_accuracy: "10"
gps:
- "{{ states('sensor.corsa_e_latitude') }}"
- "{{ states('sensor.corsa_e_longitude') }}"
mode: single```
Close
binary_sensor.corsa_e_lat is wrong
Those have to be sensor
binary_sensor.corsa_e_lat is on/off
The templates have to match the entity
and of course the gps coordinates would never be 1 or 0
description: ""
trigger:
- platform: state
entity_id:
- sensor.corsa_e_lat
- sensor.corsa_e_long
condition: []
action:
- service: device_tracker.see
data:
dev_id: "car_gps"
gps_accuracy: "10"
gps:
- "{{ states('sensor.corsa_e_latitude') }}"
- "{{ states('sensor.corsa_e_longitude') }}"
mode: single```
I can't see a way for it to accept vs in the yaml... just errors
Open your Home Assistant instance and show your state developer tools
Look there
Amusing i wasn't answering here from the same network as my home assistant panel, but i worked out where you wanted me to go!
Corsa E Lat
-1.21465 friendly_name: Corsa E Lat
sensor.corsa_e_longitude
Corsa E Long
54.55443 friendly_name: Corsa E Long```
Wiped out the _ in the copy and paste
description: ""
trigger:
- platform: state
entity_id:
- sensor.corsa_e_latitude
- sensor.corsa_e_longitude
condition: []
action:
- service: device_tracker.see
data:
dev_id: car_gps
gps_accuracy: "10"
gps:
- "{{ states('sensor.corsa_e_latitude') }}"
- "{{ states('sensor.corsa_e_longitude') }}"
mode: single
I saw what i did wrong! I removed the binary. from the start of the entity_id and didn't think the none binary sensors had a wrong name
different name ( i need some sleep obviously!)
Now try that and see if it works
To test an automation there's three stages you can follow. Testing the action, the condition and action, and the whole automation:
- Use Configuration -> Automations to find the automation and then select Run in the three dots menu. If this fails your problem is in the
action:section, and details should be found in your log file - Use Developer tools -> Services and call
automation.triggeron the automation withskip_condition: false. If the first passes but this fails then the problem is in yourcondition:block - Use Developer tools -> States to find the trigger entity, click the name, then change the state (at the top) to something that'll trigger the automation before pushing Set State. If this fails then the problem is with your
trigger:section, or the automation is turned off (you can check that in Automations, automations that are turned off will show Disabled)
You can also see this section in the docs about testing and automation traces.
Result:
params:
domain: device_tracker
service: see
service_data:
dev_id: car_gps
gps_accuracy: '10'
gps:
- -1.21465
- 54.55443
target: {}
running_script: false```
ran no problem! Phew
Now look at States for device_tracker.car_gps
I've got it on the map! Discovered something the 1 and 0 should be the other way round as the car is the middle of the Indian Ocean according to the map ๐
Just off the coast of the Seychelles
Sorted. I really appreciate all your help Tinkerer
Sent donation your way
If i want to add an image of the car to the map, i assume i just edit the known_devices.yaml and add the location of the file to the picture: line?
As a URL path
i've created www folder and uploaded the file to there so it'll just be /www/corsa.jpg
No
Okay so i have to use the full url, thanks
No
I'm reading the wrong thing then... 5 minutes
/local/corsa.jpg
I'm assuming if i want too do this for the cupra its pretty similar (however it already has a device_tracker.cupra_born_tracker)
Yes
Cool one last thing, went i reboot HA it looses the car position. I manually run the automation and it comes back, anyway to make it run more frequently or on restart?
