Integrating Hyundai Bluelink but working with Curl

Hi @Jan_Willem_Maas, I’d love to know more about #11, when I call the car-location node, I get the error “Entity API error. Error Message: required key not provided @ data[‘state’]. Got None”

image

Any help with this would be appreciated.

Do your other Bluelinky nodes work as expected?
It seems some login info is missing You need:

  • username
  • password
  • pincode
  • continent
  • vehicle identification number

Yes, I have fully working car-status and lock-car nodes

If I use the Car Location node in isolation (on new day, no other calls to the API yet) I also get an error message “Token not set”. When I manually start the flow again, I receive the proper information. Maybe the module does not handle the initial token it receives properly. What you can try is to call one of the other modules first to ensure the proper token is received and then call Car Location. If that does not work, better to contact the developers. I do not look “inside” the modules. I just use them in Node-Red and Home Assistant.

Thanks for trying Jan, I’ll try the Discord server at some point

Super cool. Would love to see this become an integration some day. I had been using an old android phone and tasker to lock and start my car. While it worked, it did not offer any of the integration. I’ve been using HA for more than 2 years and never found a reason to use Nodered, but this might be the push to try it out.

Thanks for sharing this Jan Willem. Helped me a lot :smiley:

2 questions:

How did u get the car location on the map?
And why are there delays before the car odometer and the car location

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.