Connected Cars

In this subforum you can show projects you have made, or you are busy with. Please create your own topic.

Moderator: leecollings

User avatar
FireWizard
Posts: 1747
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Connected Cars

Post by FireWizard »

If I search this forum for "Connected Cars" and in particular Volvo I don't find any post. While other Home Automation projects, like Home Assistant and OpenHAB have implemented this functionality, I thought it should be possible in Domoticz as well.
Of course it depends on the car and whether an API is available or not.

For Volvo I found a python script at Github: https://github.com/molobrakos/volvooncall and I decided to implement this.
For me using MQTT was the right way to go and as soon as you have pushed the available sensors to your MQTT broker, you can use Node-Red to push it further to Domoticz. You can even create your own "Car" plan.

I wonder if anyone has also done such an implementation in Domoticz and will share his or here useful ideas?

Some screenshots are attached.
Screenshot_Domoticz_VoC2_small.png
Screenshot_Domoticz_VoC2_small.png (200.9 KiB) Viewed 8592 times
Screenshot_Domoticz_VoC1_small.png
Screenshot_Domoticz_VoC1_small.png (245.29 KiB) Viewed 8592 times
Last edited by FireWizard on Friday 17 May 2019 23:24, edited 1 time in total.
Salammbo
Posts: 5
Joined: Saturday 19 May 2018 10:22
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Connected Cars

Post by Salammbo »

Hi,
Would you be able to share how you did achieve this?
I have a Volvo car with On call activated and have a running domoticz on a PI3.

Thank you
JimmyH1969
Posts: 153
Joined: Tuesday 28 June 2016 16:38
Target OS: Windows
Domoticz version: Beta
Location: Amersfoort NL
Contact:

Re: Connected Cars

Post by JimmyH1969 »

Thats nice, i would love to have this for my Mercedes.... looking into it :-)
DAVIZINHO
Posts: 234
Joined: Sunday 27 August 2017 18:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Spain
Contact:

Re: Connected Cars

Post by DAVIZINHO »

i have a xee device in my card but i only find information in french :-(
User avatar
FireWizard
Posts: 1747
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Connected Cars

Post by FireWizard »

I will answer the last post first, as this is the shortest of the two.
I do not own a Mercedes, so I cannot test this car. What I see on github (https://github.com/alfonsojimenez/mercedes) that someone developed an API in order to communicate with the car. The response is similar to what the Volvo API does.
E.g. Home Assistant had integrated a mercedesme component. See https://www.home-assistant.io/components/mercedesme.
However from their website:
The component was removed. The vendor disabled the API endpoint and a new API is not available currently.
So there is not much I can do for you. I advise you, as you are a Mercedes owner, to monitor if at some stage a new API will come available.
Then it might be possible to use it in combination with Domoticz or any other Home Automation system.

As I own a Volvo I decided to use a python script, developed by molobrakos, and also used by Home Assistant and OpenHab.
My idea was, as it works there it should be possible to make it work with Domoticz as well.

First you should know my current set-up of Domoticz.
My production Rasperry Pi is a RPi2 and I leave this Pi as much as possible untouched. All my tests are carried out on a RPi1, before I transfer a script or plug-in to my production pi. This Pi1 runs as a slave domoticz device of the Pi2 (master).
On this Pi1 I have also installed Mosquitto MQTT broker, NodeJS and Node-Red.
In order not to break the Pi1 and Pi2 I decided to install the Volvo on Call python script on another pi (RPi3+)
I assume that it is possible to install the Mosquitto broker, NodeJS, Node-Red and the VoC script together with Domoticz on the same Rpi.

The first requirement is that you have a valid subscription to the VoC service.
If so, then it's time to go.

I assume that you have installed the latest Raspbian Stretch and upgraded all the packages.
Also a static (fixed) IP address is recommended. I assume also that you use ssh access.

1. Install Mosquitto MQTT broker.
There are many guidelines on the Internet available.
E.g. See: https://appcodelabs.com/introduction-to ... spberry-pi
Test your MQTT broker, so that you know that it is working properly. Install also mosquitto-clients.

A tool, I use, on the desktop is MQTTfx. (See https://mqttfx.jensd.de/) But there are many others.

Test that you can connect with your tool to the Mosquitto broker. Default port is 1883.

Do not forget to secure your broker with at least username/password.

2. Install in Domoticz the MQTT Client Gateway with LAN interface and fill in the required fields
See:
MQTT Domoticz.png
MQTT Domoticz.png (134.46 KiB) Viewed 8213 times
Check that you can communicate between Domoticz and the MQTT Broker.
Subscribe with any client to domoticz/out and you will see various messages passing.

3. As the VoC script requires Python 3.6 or higher we have to update python.
Follow the guideline:
https://www.scivision.dev/compile-insta ... pberry-pi/
OR
https://gist.github.com/SeppPenner/6a5a ... 524417761d

Verify always: python -V
Yesterday, March 25, the latest version of python 3.7.3. has been published.
Adapt your version numbers accordingly.

4. Install the VoC python script from molobrakos in any folder you like, preferably your home directory (/home/pi) .
It's recommended that this folder is added to your path.
git clone https://github.com/molobrakos/volvooncall

Insert your credentials, like username (emailaddress) and password into: .voc.conf
These are equal to the one you use in your app.

Configuration file in $HOME/.voc.conf:

username: <username>
password: <password>

Now it is time to test.

Give the following command:
pi@rpi3plus:~ $ voc --help

You will get:

Retrieve information from VOC

Usage:
voc (-h | --help)
voc --version
voc [-v|-vv] [options] list
voc [-v|-vv] [options] status
voc [-v|-vv] [options] trips [(--pretty|--json|--csv)]
voc [-v|-vv] [options] owntracks
voc [-v|-vv] [options] print [<attribute>]
voc [-v|-vv] [options] (lock | unlock)
voc [-v|-vv] [options] heater (start | stop)
voc [-v|-vv] [options] engine (start | stop)
voc [-v|-vv] [options] honk_and_blink
voc [-v|-vv] [options] call <method>
voc [-v|-vv] [options] mqtt
voc [-v|-vv] [options] dashboard

Options:
-u <username> VOC username
-p <password> VOC password
-r <region> VOC region (na, cn, etc.)
-s <url> VOC service URL
-i <vin> Vehicle VIN or registration number
-g Geolocate position
--owntracks_key=<key> Owntracks encryption password
-I <interval> Polling interval (seconds) [default: 300]
-h --help Show this message
--immutable Read only mode
-v,-vv Increase verbosity
-d More debugging
--scandinavian_miles Report using Scandinavian miles instead of km ISO unit
--utc Print timestamps in UTC (+00:00) instead of local time
--version Show version

So if this works your fine.
Test further with voc dashboard and you will find a lot of information of your car.
To see everything that might be supported for your car issue the command voc print.

Steps 1 and 2 might not be be necessary if you are able to write a script in e.g. Lua or dzVents and to read the values directly from voc and use them in Domoticz (if everything is running on the same Pi).

However in my case the voc script and Domoticz (production) run on different RPi's.
So I publish all the topics with voc mqtt to my Mosquitto MQTT broker on another pi.
If you want to do that you have to add the following line to .voc.conf:
mqtt_url: mqtt://<username of mqtt broker>:<password of mqtt broker>@192.168.xxx.yyy:1883
(if you use the default port and without<>)

Check with your client, that voc mqtt publishes all sensors under the following topic: volvo/abc123/#
abc123 is your number plate.

On this pi I have installed NodeJS and Node-RED according to this guide:
NodeJS: https://www.instructables.com/id/Instal ... spberry-Pi
Node-RED: https://nodered.org/docs/getting-started/installation

If this all works you can start to read all the published topics into node red and to convert the messages and to re- publish them again to domoticz/in.
Create the necessary virtual switches and sensors in Domoticz. Note down their idx. If you want all, you need approx 30-35 sensors/switches.

I hope this guide helps you with the first steps.
In the process you will come across various problems/questions/ideas.
Do not hesitate to ask.
Last edited by FireWizard on Wednesday 27 March 2019 20:35, edited 1 time in total.
User avatar
FireWizard
Posts: 1747
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Connected Cars

Post by FireWizard »

To DAVIZINHO:

Regarding XEE I see some info in English
https://dev.xee.com/v4-openapi/

At https://dev.xee.com/signals, I see that a lot of info is available.
If you have access to a xee account you can read the API directly into Node-Red and from there it is more or less the same route to Domoticz.
User avatar
mkeuzenkamp
Posts: 6
Joined: Wednesday 27 March 2019 7:45
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Location: Purmerend
Contact:

Re: Connected Cars

Post by mkeuzenkamp »

Hi,

Can you only retrieve information or also send commands like
lock car
start heater
and so

Tnx
Martin
User avatar
FireWizard
Posts: 1747
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Connected Cars

Post by FireWizard »

Hi Martin,

You can retrieve a lot of information, more or less the same you can get in your app.
You can also send commands, both directly from the command line and publish these commands to the MQTT broker.
The VoC script has subscribed to the commands.
Which commands depends on the car, but if you can lock and unlock, switch on or off your heater, or start your engine from the app you can do it also from this application.
The only command that does not work yet, is remote honk and blink. I don't use this functionality hardly, so it has very low priority for me.
I use only lock/unlock and heater on/off.
Car_Switch.png
Car_Switch.png (110.11 KiB) Viewed 8147 times
Best regards.
User avatar
mkeuzenkamp
Posts: 6
Joined: Wednesday 27 March 2019 7:45
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Location: Purmerend
Contact:

Re: Connected Cars

Post by mkeuzenkamp »

Hi Firewizard,

Thanks very much. I have a Volvo V60 with lots of functions (start stop heater is most of my interest)
I am trying to follow your descripion to implement the switches to Domoticz

Thanks so far

Martin
User avatar
FireWizard
Posts: 1747
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Connected Cars

Post by FireWizard »

Hi Martin.

Do it as a step by step process.

1. Upgrade python to at least v3.6
2. clone from github the voc script.
3. Create the ~/.voc.conf with your username and password (identical as in your app)
4. Test if voc is running by: $ voc help
5. Test you connection to the voc server: $ voc print, and see what your car supports.
6. Install mosquitto and mosquitto-clients
7. Install a client and test that mosquitto is running.
8. Run voc mqtt
9. See if many topics are published.

Post your result and ask in case of questions or problems

Success

Fire Wizard
Last edited by FireWizard on Wednesday 30 October 2019 22:24, edited 2 times in total.
User avatar
mkeuzenkamp
Posts: 6
Joined: Wednesday 27 March 2019 7:45
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Location: Purmerend
Contact:

Re: Connected Cars

Post by mkeuzenkamp »

Hi Fire Wizard

Sorry for late response. I managed to install, and voc is running. But testing the connection is not succesfull. So I will start searching for topics to see if I can fix this.

update 20190403 23:45 It is working from command promt. Next step connect to Domoticz

Regards,
Martin
User avatar
FireWizard
Posts: 1747
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Connected Cars

Post by FireWizard »

Hi Martin,

You don't have to make apologies for a late answer. It is still a hobby project and you can answer, when you have time.

That it works from the command prompt means that you have successfully configured the access to the VoC server and you can now receive information from it, using the commands as presented under usage. See above.
If you give the command voc print you will get all supported functionality.

How to continue?
This depends on your programming/scripting skills and your setup.
If you have installed the VoC script on the same Raspberry Pi as where Domoticz has been installed you could write a Lua or dzVents script and present the data you get from e.g. the command "voc dashboard". If you have installed the VoC script on a different computer or Raspberry Pi it would be better to publish the data to a MQTT broker. This approach can also be followed if the VoC script and Domoticz are running on the same Raspberry Pi.
If you go for scripting or write a program I hope to see a result sooner or later.
If you go for the MQTT approach follow the guide line below.

1. Install Mosquitto broker according to:
https://theembeddedlab.com/tutorials/in ... pberry-pi/

There are more tutorials available on the Internet but this one is up te date and complete.
A word about security, if you plan to expose your MQTT server (broker) to the public Internet.
Use at least a username and a hard to guess password.
Except if you want to develop some python program with mosquitto you don't need any mosquitto python module.

Test you mosquitto broker as described.
You can start it from the command line with the command "mosquitto &".
It is preferred to run as a service.

It is also recommended to install a Mosquitto client on your Desktop or Laptop, like MQTTfx (See link above)

In order to publish all available data to the mosquitto broker you have to change your .voc.conf file, which you will find in your home directory (Probably /home/pi)
$ nano .voc.conf
Insert the first line (without< and>):

mqtt_url: mqtt://<username mosquitto>:<password mosquitto>@<ip address or localhost>:1883
username: <email address>
password: <VoC password>

The default polling time is 300 seconds, but you can change that.
An update every 5 minutes is fine for me.

In order to start to voc script also after a reboot

Create a file with a name you like; mine is called voc-mqtt.service.
Insert the following contents:

[Unit]
Description=voc-mqtt
After=network-online.target

[Service]
Type=simple
ExecStart=/home/pi/.local/bin/voc mqtt
Restart=always
RestartSec=1
User=pi
Group=pi

[Install]
WantedBy=multi-user.target

If you run the script as user pi and you have it installed in /home/pi/.local/bin you don't have to change anything.
Next:
sudo cp voc-mqtt.service /etc/systemd/system/voc-mqtt.service

Test the script.
sudo systemctl start voc-mqtt.service
and stop it: sudo systemctl stop voc-mqtt.service
If this all works issue the command: sudo systemctl enable voc-mqtt.service.

Now the VoC script will publish a lot of topics to the broker.
You can connect to the broker and e.g. subscribe to all messages, using the hash (#) sign.

The next step is to install the MQTT Client Gateway with LAN interface (see above)
Check with your client that you can subscribe to domoticz/out.
You will see a lot of messages from Domoticz.

If this all works you can start to install NodeJS and Node-Red. See the links above.
If this is succesfull then the link between MQTT and Domoticz can be made.

So far.

Regards,
FireWizard
evertide
Posts: 14
Joined: Wednesday 19 November 2014 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Contact:

Re: Connected Cars

Post by evertide »

Hi Firewizard,

Great post and interesting solution.

I got voc working including mqqt /node red etc. However I am struggling a bit with the node red flows.

Would you be able to export some flows for guidance . I am particular interested in the engine/heater/lock state and switching them.

My mind is at the use case, If it is a week day , the temp is below 0 , I am home and warm water was used around 7 am there is properly a good reason to warm up the car ;-).

Thanks


Verzonden vanaf mijn iPad met Tapatalk
User avatar
FireWizard
Posts: 1747
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Connected Cars

Post by FireWizard »

Hi Evertide,

Sure I'm prepared to publish the flow(s) and to support you in get it to work.

I assume that (as you said) voc is running, preferable as a service, and that you, if you issue on the command line the following command: voc print, you get all supported functions and you will also see the unsupported functions.
Are you already able to connect to the Mosquitto broker with a MQTT client? If so, do you see the messages from Volvo on Call?

The complete Volvo on Call consist of several flows.

1. Various sensors from VoC to Domoticz.
2. Various commands from Domoticz to VoC.
3. Special functions to Domoticz, such as:
- Temperature at the car
- Location of the car.
- Integration with Owntracks

If you can confirm above, I will provide a description on how to do it and publish the flows tomorrow.
I suggest that we do it step by step.

Regards
evertide
Posts: 14
Joined: Wednesday 19 November 2014 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Contact:

Re: Connected Cars

Post by evertide »

Hi

The VOC Mqtt as a service is working as a charm and I am getting the flood of VOC messages if I subscribe to the topic.

The small challenge was the .voc.conf file with username and password for my MQTT broker. (and there needs to be a space between the colon(:) and the username and password.

.voc.conf
username: [email protected]
password: secure_password!
mqtt_url: mqtt://secure_user:secure_password!@localhost:1883

Regards
User avatar
FireWizard
Posts: 1747
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Connected Cars

Post by FireWizard »

Hi,

That is correct. There has to be a space after the : for both username, password and mqtt_url.
I did not mention it explicitely in my posts. The mqtt_url line is not necessary, if voc and mosquitto run on the same machine.

I will make a flow description and publish the flow later today.
I do not have access to my Node Red at the moment.

Regards
User avatar
FireWizard
Posts: 1747
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Connected Cars

Post by FireWizard »

Hi all,

My apologies, that I did not kept my promise, to publish a flow description on Thursday. I had to solve some other issues.
As I can only publish 3 screenshots at the time, I have created a PDF document, that I hereby like to share.
You can download the file at: https://github.com/FireWizard52/Volvo-o ... ticz-Howto
Feel free to read it. I'm open for comments, suggestions, improvements, both regarding the document, as the published flows.

Best regards
Last edited by FireWizard on Monday 11 November 2019 18:38, edited 1 time in total.
evertide
Posts: 14
Joined: Wednesday 19 November 2014 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Contact:

Re: Connected Cars

Post by evertide »

Thanks massively, very detailed and very good. I will give it a go next week.

Regards


Verzonden vanaf mijn iPad met Tapatalk
User avatar
FireWizard
Posts: 1747
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Connected Cars

Post by FireWizard »

Hi all,

I have just published a new and final version of the pdf document Volvo-on-Call-to-Domoticz-Howto.pdf on github
Feel free to read it. I'm open for comments, suggestions, improvements, both regarding the document, as the published flows.

You can download the file at: https://github.com/FireWizard52/Volvo-o ... ticz-Howto

Regards
evertide
Posts: 14
Joined: Wednesday 19 November 2014 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Contact:

Re: Connected Cars

Post by evertide »

Hi,

The temp and location is a good addition to the document, Thanks.

Two question on the document.

1- you have both the lock,heater and engine in a text information box and actual switch status? What is the thinking behind that?

2- There is mention to add the engine start command in the document but the mqtt topic is not mentioned. Would you be able to share

Regards
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest