Integrating Hyundai Bluelink but working with Curl

To start with your second question: I noticed that Odometer and Location sometimes gives an error message “Token not set”. I tried several things to work around this. One approach that is effective is to call these nodes two times right after the other. The second time the error disappears. In the example you have, I worked on the hypothesis that the Odometer and Location node need more time for data to come in (like the token) after the Status node is called. But I do not think that hypothesis is right. It is best to have the node authors resolve this. Just call the node twice as a working work around.

I will give the first question a shot in a separate reply.

To get the car location on a map you do the following.
Go to Google Maps and get a google maps key. It takes some searching for the right entry point. You need to leave your credit card, but that is not an issue because your will stay way below the monthly maximum number of calls for invoicing to start.
In Home Assistant create two MQTT sensors for latitude and longitude (that get filled by Bluelinky in Node Red).
Then in Home Assistant create a generic camera in camera.yaml as follows:

  - platform: generic
    name: car location
    limit_refetch_to_url_change: true
    still_image_url: >-
      https://maps.googleapis.com/maps/api/staticmap?
      center={{states("sensor.ev_latitude") + ", " + states("sensor.ev_longitude")}}
      &zoom=15
      &size=600x600
      &maptype=roadmap
      &markers=color:red|label:H|{{states("sensor.ev_latitude")}},{{states("sensor.ev_longitude")}}
      &key=YourGoogleMapsKey

Make sure you add the “limit_refetch_to_url_change: true”, because this significantly reduces the number of calls to google maps. I forgot to put it in, and I quickly racked up a large number calls to the google maps api.
You can tinker with zoom, size and map type. I took the car’s coordinates as the center of the map. I took the letter H as the marker (for Hyundai) but it can be any letter. Please note the vertical bar “|” behind the letter H.
Then in Lovelace add the camera to the front end.
I only call for car status, location and odometer manually with a fake button calling a script, because I read somewhere that Hyundai does not look kindly to us calling every 10 minutes or so. Plus it drains the small battery very fast if there are too many calls.
I hope you enjoy. Let me know if you find a way to improve on this.

I use device_tracker.see service to create a device tracker based on lat and lon and then just show it on a standard HA map card

1 Like

Thnx Jan Willem & Holdestmade. I read about your solution Jan Willem and i know it works, but my api doesn’t work because i don’t use a credit card. The solution Holdestmade uses works great.

- id: '1605652742030'
  alias: Carpinpoint
  description: ''
  trigger:
  - platform: state
    entity_id: sensor.kona_latitude, sensor.kona_longitude
  action:
  - service: device_tracker.see
    data_template:
      dev_id: kona
      gps:
      - "{{ states('sensor.kona_latitude') }}"
      - "{{ states('sensor.kona_longitude') }}"
  mode: single

Now that is what I call a reward for sharing things. Really nice and much simpler than mine.
By the way, this does not work on its own. I probably need to do:

  1. Configure a device tracker (I have none now)
  2. Edit known_devices.yaml to include “kona” as a device name, what else to include? No Mac, but likely “track: true”?
    Or maybe easier if you copy the relevant yaml entries.

Thanks,

You just need to create an automation. The device tracker will be made from the lat & lon sensor of your vehicle. See my example in the previous post

In my known_devices i see

kona:
  name: kona
  mac:
  icon:
  picture:
  track: true

Tx, much simpler than I thought

First of all thanks to all of you for making it so easy to use bluelinky with node-red in HA.
The get status and odometer is working perfectly fine. But how does it work with lock/unlock car?
I was thinking it’s working the other way around with a “mqtt in” but I have no idea what to send.

Thanks in advance!

I think I’m very close on this but I’m missing something. I added what is below to my known devices and after rebooting I see it in devices but it isn’t setup as a GPS tracker. I’ve read up and down through this thread and I’m thinking that I just didn’t setup the device properly but can’t figure out how to add it. Any help would be appreciated.

Palisade:
name: Palisade
mac:
icon:
picture:
track: true

Just create an automation based on your car’s longitude and latitude, then the car automaticly comes in your known devices.

- id: '1605652742030'
  alias: Carpinpoint
  description: ''
  trigger:
  - platform: state
    entity_id: sensor.kona_latitude, sensor.kona_longitude
  action:
  - service: device_tracker.see
    data_template:
      dev_id: kona
      gps:
      - "{{ states('sensor.kona_latitude') }}"
      - "{{ states('sensor.kona_longitude') }}"
  mode: single

I still must be missing something because it isn’t working. In Home Assistant I am going to the “Configuration->Automations” and selecting “Edit as YAML”. I then paste in the following:

> alias: PalisadeLocation
> description: ''
> trigger:
>   - platform: state
>     entity_id: 'sensor.palisade_latitude, sensor.palisade_longitude'
> action:
>   - service: device_tracker.see
>     data_template:
>       dev_id: palisade
>       gps:
>         - '{{ states(''sensor.palisade_latitude'') }}'
>         - '{{ states(''sensor.palisade_longitude'') }}'
> mode: single

Did you have to setup the kona device prior to this?

Check your quote types:

    - "{{ states('sensor.palisade_latitude') }}"
    - "{{ states('sensor.palisade_longitude') }}"

So I thought I was on to something because I see that the quotes are definitely different after I enter them. I updated all of them and even tried cutting and pasting exactly what Gat0r had and it reverts back to the quotes that I have. Can someone please confirm that I’m entering the automation correctly? I am going into Configuration->Automations and choosing “+ ADD AUTOMATION”. I then choose “Start with an empty automation” and in the upper right hand corner I select the three dots and select “Edit as YAML”. I’ve also tried just putting this in to the automations.yaml and Executing but nothing seems to happen. I feel really dumb but I’m not connecting the dots somewhere here or my HA isn’t working the same as others.

That’s correct and worked on my side, vehicle should be listed in the Automations tab afterwards.
Are you able to safe the automation or do you get an error message?

Maybe my .yaml helps you to compare?

alias: Hyundai Tracking
description: Tracking des Ioniq
trigger:
  - platform: state
    entity_id: 'sensor.hyundai_latitude, sensor.hyundai_longitude'
action:
  - service: device_tracker.see
    data_template:
      dev_id: hyundai_ioniq
      gps:
        - '{{ states(''sensor.hyundai_latitude'') }}'
        - '{{ states(''sensor.hyundai_longitude'') }}'
mode: single

It seems that most of you seems to prefer to do the updates to the device tracker through automations in HA and that is also how I normally been prefering to do things.

But now being forced to start to use Node-Red to get this integration, I started to learn also that tool some more.

It is quite simple to create/update the device tracker directly from node red by using the call service node and just adding this to the data field (also adding the correct domain and service in the node config):

{
    "dev_id": "whatever you name your car",
    "gps": [
        "{{payload.latitude}}",
        "{{payload.longitude}}"
    ]
}

This was the device tracker is updated every time the call is made without depending on some specific triggers.

Thanks for the reply and for the assistance. I started over and cut/pasted your YAML in and just updated for my vehicle and it still doesn’t seem to be working. There were no errors and I even “Execute” that automation. I can’t tell if anything is happening but there are no errors. From what I’m reading I feel like a new entity called device_tracker.hyundai_palisade should now exist but it doesn’t . Did you manually add hyundai_ioniq to your known_devices.yaml?

Also, in your Device list can you show me what you see? My source_type is showing null and not gps so it doesn’t have latitude and longitude as attributes.

Actually, I think I got it to work with node-red! I used Domain:device_tracker, Service: see and pasted in what you suggested into Data. When I test it this time it worked!

1 Like

I can’t seem to win here. I do have this working with Node-Red (kind of). When I have the Node-Red window open it works fine. When it isn’t open it doesn’t work and when I come back into Node-Red I get a message underneath the call device_tracker.see service that says “API Error”. I’m trying to use the “Get Location” hourly. Is anyone else having this issue or know why this would error out. When I have node-red open the exact same logic works fine.

After having it working for over a month I do now have the “get …” nodes marked with error.
That can only relate to the credentials right? I have no idea why this happened … did anyone else experience this?

Yes I have the same. Looking on other sites, it looks like the API has changed.

1 Like