Step 1, do you know how to program and use curl? FYI. I found a group that had already started what I wanted. I am just working with them.
No actually not.
Please keep me updated! I am very curious.
It works great. I am using it through code-red now. Developers are super nice too.
Could you please share what you’ve found, either a link to it, or the code here?
Thanks!
Hey mrand, I think he just had a typo. The npm for bluelinky has been made into an integration for Node-Red. With that, it’s pretty trivial to get it going with home assistant.
I’m using the hassio add ins for Node-Red and was able to get car status and lock/unlock the doors.
Thanks for confirming the node-red version works (I did notice the reversed words). I am also interested if @downbound had successfully done it with curl - I can’t quite tell from his wording.
Hi! I’m one of the main contributors for bluelinky. I just want to note that i’m an active Home Assistant user myself, and that if you want to discuss usage and integration, you are very welcome to our Discord server https://discord.gg/HwnG8sY
I do not use curl, because with the clues in this thread I found a much easier method using Node-Red (I had never used Node-Red before).
The steps I took were as follows:
- Within Home Assistant get the Node-Red Add-on in the Add-on store.
In the configuration tab configure the following items:
credential_secret: your_secret
http_node:
username: pick_your_name
password: pick_your_pwd
http_static:
username: pick_your_name
password: pick_your_pwd
ssl: true
certfile: fullchain.pem
keyfile: privkey.pem
require_ssl: true
system_packages: []
npm_packages:
- node-red-contrib-bluelinky
I am on SSL, but you may not be. You now have the Node-Red Bluelinky package installed.
-
Now you need to be ready to input your login details for the Bluelink App, your pincode for the app and your VIN: vehicle identification number. This last number is in your car’s official papers.
-
In the left hand column of Home Assistant click on Node-Red. This loads all the required packages, including Bluelinky
-
Scroll down to the greenish buttons in the left hand column and pull the “Car Status” item listed under Bluelinky into the workspace. If you click on it you can configure this node with the data above. Do not forget to fill in the Region and the car’s brand. These are required.
-
Under Common pull the Inject node into the workspace and link its output to the input of the Car Status. Now hit deploy (“Save”) in the top right corner. If you now press the left most button of the Insert node, the status data will be collected from the car. This command downloads a JSON file with a lot of useful date. But of course you cannot see this yet because we have not configured any output node.
-
To get a handle on the data you can connect a “Debug” node to the Car Status node. You can view the debug message if in the top right menu you select to show debug messages in the sidebar. If you click on the debug message you will see the JSON file structure.
-
Now for getting a useful data element out of the JSON. For instance to get the “Range” in km from the JSON you insert a “Change” node after the Car Status node and connect it to the Car Status output. Then you need to configure the “Change” node. Essentially you change the “msg.payload” which is the whole JSON file into the element you’d like to have: “msg.payload.status.engine.range” as follows:
The output of the “Change” node will now be the range of your car in km.
The data’s path may have changed, it happened to me too. You therefore need to find the right path in the json file by clicking on the relevant data point and then copy the path by clicking on the “>_” button in the column on the right in the debug window.
-
The next challenge is showing this data point in Home Assistant. Not knowing much about Node-Red the easiest for me was to send a MQTT message to the MQTT broker which I have already configured on my system. You can send this MQTT message by getting the “MQTT out” node into your workspace. Connect the output of the “Change” node to the input of “MQTT out”. Then configure this node, by clicking on the input field for MQTT broker. Since my broker is running on my Pi, I just filled in “localhost” with the standard “1883” port number. Under the “Security” tab include your Username and Password for the MQTT broker. Then lastly fill in the Topic for this message, that Home Assistant needs to recognise. I used: “ev/engine/range” as a topic for this data point. Do not forget to deploy your flow now and again, otherwise you will lose your input.
-
The last step is to configure a MQTT sensor in Home Assistant. My sensor for this data point is as follows:
- platform: mqtt
name: "EV engine range"
state_topic: "ev/engine/range"
unit_of_measurement: "km"
Restart Home Assistant. Then if all is well, your range datapoint is defined as “sensor.ev_engine_range”. You can show this sensor in the Lovelace front end.
-
Now that you have the data in HA, you will want to automate this. You do this by formatting the Inject node to “Repeat” at regular intervals. I started with every five minutes. However after about 24 hours I saw the small 12 Volt battery draining itself rather quickly. I now call the data once per 24 hours, and I created a button for Lovelace to manually update the data, when I call the relevant page. But that is a different topic altogether. Willing to show what I did. Send me a message.
-
In the data you will also see the car’s geo coordinates. I use these coordinates to plot the car with a marker on a google maps picture. This took quite a bit of tinkering, but I did get it to work. Send me a message if anyone would like to see what I did.
-
So here are some screen shots of all the flows for car data:
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”
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
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
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:
- Configure a device tracker (I have none now)
- 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,