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: 1745
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 »

Hello evertide,

My current car has only the possibility to remotely lock and unlock the tailgate. If you press the button underneath the tailgate, it will unlock all other doors. Remember, you will not see any flashing lights, when you use remote unlock and you have to press the button underneath the tailgate within 2 minutes, otherwise it will automatically lock again. My previous car had the possibility to control the heater, but as this is no longer the case, I had to remove this button (switch). The possibility to start/stop the engine has never been available to me.

You wrote:
1- you have both the lock,heater and engine in a text information box and actual switch status? What is the thinking behind that?
The thoughts behind it are as follows:

1. Volvo on call publishes the following topics:
volvo/abc123/lock/lock/state : msg.payload : string[4]: "lock"
volvo/abc123/binary_sensor/is_locked/state : msg.payload : string[2]: "on"

You can check this by connecting a debug node to the MQTT input node, called MQTT-VoC Out.

Beside that you can issue from the command line, the command: $ voc dashboard
It will give you the following information about the lock/unlock state:

ABC123 Door lock : Unlocked
AND
ABC123 Door lock : Off

A little strange. For the heater and the engine you have only one line ABC123 Door lock : Off and ABC123 Door lock : Off.

However, you are able to lock/unlock your car in various ways:
1. Use your car keys
2. Use your car remote
3. If you have so called "Key less entry", you can approach your door lock.
4. Use the lock/unlock of your Volvo on Call app
5. This Domoticz solution

The first topic (volvo/abc123/lock/lock/state) is published to the text sensor. The second topic (volvo/abc123/binary_sensor/is_locked/state) is published to the switch. The idea behind it is, that the indication of the switch (On/Off) is also synchronized if one one of the other methods for lock/unlock has been used.

For the heater, only volvo/abc123/switch/heater/state : msg.payload : string[3]: "off", is available. As I do not own a car with a heater, that can be activated remotely, I send only a message to a Text sensor. In my old car I could activate the switch, but in the document it is commented. This topic has also been used in order to synchronize the heater switch, if the heater had been activated by the Volvo on Call app.

The same applies for the engine. Only volvo/abc123/binary_sensor/is_engine_running/state : msg.payload : string[3]: "off",is available. Itś sending a message to a Text sensor.
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
The reason that I did not describe that topic, is that it has never been available to me.
But if you can support me with that, I can include it in the document.

You can do it as follows:

1. Go to the command line and issue the command: $ voc print|grep engineStart
You will get the following reply: "engineStartSupported": false, It shall be either true or false. If it is false, remote engine start is not supported. If the reply is "engineStartSupported": true, can you check with a MQTT client, such as MQTTfx, which topics are published to the MQTT server.
You can download MQTTfx at: https://mqttfx.jensd.de/, and look what is published regarding engine, if you subscribe to: volvo/abc123/#.
At least you should see:
volvo/abc123/binary_sensor/is_engine_running/avail and volvo/abc123/binary_sensor/is_engine_running/state.
If there is more, please publish this topic.

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,

A small update on where I ended up with. (Kudos to FireWizard).

Domoticz setup:
capture2.png
capture2.png (54.85 KiB) Viewed 3499 times
Node red flow:
Capture.PNG
Capture.PNG (95.22 KiB) Viewed 3499 times


below (inside the spoiler text) the node red export.
Spoiler: show
[{"id":"494c88d0.ac5ca8","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"112d2046.4bd2d","type":"mqtt in","z":"494c88d0.ac5ca8","name":"MQTT-VOC-Out","topic":"volvo/aplate1/+/+/state","qos":"2","datatype":"auto","broker":"6fc03d79.ef77e4","x":200,"y":340,"wires":[["f9d2f0b4.efa2","b723d201.f91a5"]]},{"id":"f9d2f0b4.efa2","type":"debug","z":"494c88d0.ac5ca8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":190,"y":520,"wires":[]},{"id":"b723d201.f91a5","type":"routing","z":"494c88d0.ac5ca8","name":"","rules":[{"v":"volvo/aplate1/*path"},{"v":"volvo/aplate1/sensor/trips/state"}],"outputs":2,"x":410,"y":340,"wires":[["4977b31d.c07c4c","5d6d2da8.df0b84","62d08b26.226364"],["82f1fe41.21d95","42b75197.a8f48"]]},{"id":"4977b31d.c07c4c","type":"debug","z":"494c88d0.ac5ca8","name":"Output 1 Path","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":420,"y":520,"wires":[]},{"id":"82f1fe41.21d95","type":"debug","z":"494c88d0.ac5ca8","name":"Trips","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":390,"y":580,"wires":[]},{"id":"5d6d2da8.df0b84","type":"function","z":"494c88d0.ac5ca8","name":"Convert Binary","func":"// Function node for Binary Sensors\n// Declare variables\nvar number_plate = \"aplate1\";\n// Binary Sensors which will give alert\nif (msg.topic == \"volvo/\" + number_plate + \"/binary_sensor/any_door_open/state\"){\nif (msg.payload == \"close\") {\nmsg.payload = {\"command\":\"udevice\",\"idx\":902,\"nvalue\":1,\"svalue\":\"Closed\"};\n} else {\nmsg.payload = {\"command\":\"udevice\",\"idx\":902,\"nvalue\":4,\"svalue\":\"Open\"};\n}\nreturn msg;\n}\nif (msg.topic == \"volvo/\" + number_plate + \"/binary_sensor/any_window_open/state\"){\nif (msg.payload == \"close\") {\nmsg.payload = {\"command\":\"udevice\",\"idx\":903,\"nvalue\":1,\"svalue\":\"Closed\"};\n} else {\nmsg.payload = {\"command\":\"udevice\",\"idx\":903,\"nvalue\":4,\"svalue\":\"Open\"};\n}\nreturn msg;\n}\nif (msg.topic == \"volvo/\" + number_plate + \"/binary_sensor/service_warning_status/state\"){\nif (msg.payload == \"safe\") {\nmsg.payload = {\"command\":\"udevice\",\"idx\":904,\"nvalue\":1,\"svalue\":\"All Good\"};\n} else {\nmsg.payload = {\"command\":\"udevice\",\"idx\":904,\"nvalue\":4,\"svalue\":\"Service required\"};\n}\nreturn msg;\n}\n// Binary Sensors as switch\nif (msg.topic == \"volvo/\" + number_plate + \"/binary_sensor/is_engine_running/state\"){\nif (msg.payload == \"off\") {\nmsg.payload = {\"command\":\"udevice\",\"idx\":905,\"nvalue\":0,\"svalue\":\"Off\"};\n} else {\nmsg.payload = {\"command\":\"udevice\",\"idx\":905,\"nvalue\":1,\"svalue\":\"On\"};\n}\nreturn msg;\n}\nif (msg.topic == \"volvo/\" + number_plate + \"/lock/lock/state\"){\nif (msg.payload == \"lock\") {\nmsg.payload = {\"command\":\"udevice\",\"idx\":906,\"nvalue\":1,\"svalue\":\"Locked\"};\n} else {\nmsg.payload = {\"command\":\"udevice\",\"idx\":906,\"nvalue\":0,\"svalue\":\"Unlocked\"};\n}\nreturn msg;\n}\nif (msg.topic == \"volvo/\" + number_plate + \"/sensor/trips/state\"){\nmsg.payload = {\"command\":\"udevice\",\"idx\":908,\"nvalue\":0,\"svalue\":(msg.payload)};\nreturn msg;\n}","outputs":1,"noerr":0,"x":660,"y":300,"wires":[["e226c51c.731b88","7c7bc71c.2d6bc8"]]},{"id":"7c7bc71c.2d6bc8","type":"rbe","z":"494c88d0.ac5ca8","name":"changed?","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":980,"y":300,"wires":[["f75a77e4.c36508","b07bb985.99f4c8"]]},{"id":"e226c51c.731b88","type":"debug","z":"494c88d0.ac5ca8","name":"Binary","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":720,"y":520,"wires":[]},{"id":"f75a77e4.c36508","type":"mqtt out","z":"494c88d0.ac5ca8","name":"","topic":"domoticz/in","qos":"","retain":"","broker":"6fc03d79.ef77e4","x":1250,"y":320,"wires":[]},{"id":"62d08b26.226364","type":"function","z":"494c88d0.ac5ca8","name":"Analog Sensors","func":"// Function node for Analog Sensors\n// Declare variables\nvar number_plate = \"aplate1\";\n// Sensors Analogue values\nif (msg.topic == \"volvo/\" + number_plate + \"/sensor/odometer/state\"){\nmsg.payload = {\"command\":\"udevice\",\"idx\":909,\"nvalue\":0,\"svalue\":(msg.payload)};\nreturn msg;\n}\nif (msg.topic == \"volvo/\" + number_plate + \"/sensor/fuel_amount_level/state\"){\n msg.payload = {\"command\":\"udevice\",\"idx\":910,\"nvalue\":0,\"svalue\":(msg.payload)};return msg;\n}","outputs":1,"noerr":0,"x":660,"y":340,"wires":[["c706b2d8.fd47d","88c07e9d.c0b4"]]},{"id":"c706b2d8.fd47d","type":"debug","z":"494c88d0.ac5ca8","name":"Analog","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":720,"y":580,"wires":[]},{"id":"b07bb985.99f4c8","type":"debug","z":"494c88d0.ac5ca8","name":"Binary Unchanged out","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1040,"y":520,"wires":[]},{"id":"42b75197.a8f48","type":"moment","z":"494c88d0.ac5ca8","name":"Date","topic":"","input":"","inputType":"msg","inTz":"Europe/Amsterdam","adjAmount":0,"adjType":"days","adjDir":"add","format":"DD-MM-YYYY HH:mm:ss","locale":"en_US","output":"","outputType":"msg","outTz":"Europe/Amsterdam","x":550,"y":440,"wires":[["5d6d2da8.df0b84"]]},{"id":"14521bb3.8170d4","type":"mqtt out","z":"494c88d0.ac5ca8","name":"VOC Out","topic":"","qos":"","retain":"","broker":"6fc03d79.ef77e4","x":1240,"y":120,"wires":[]},{"id":"bace919a.3528f","type":"debug","z":"494c88d0.ac5ca8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":200,"y":180,"wires":[]},{"id":"c947644b.4c0608","type":"mqtt in","z":"494c88d0.ac5ca8","name":"","topic":"domoticz/out","qos":"2","datatype":"auto","broker":"6fc03d79.ef77e4","x":210,"y":120,"wires":[["bace919a.3528f","5be29676.03fbd8"]]},{"id":"5be29676.03fbd8","type":"json","z":"494c88d0.ac5ca8","name":"","property":"payload","action":"","pretty":true,"x":490,"y":120,"wires":[["f89aff0f.b81f6","5fae9627.af13f8"]]},{"id":"f89aff0f.b81f6","type":"debug","z":"494c88d0.ac5ca8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":490,"y":180,"wires":[]},{"id":"5fae9627.af13f8","type":"function","z":"494c88d0.ac5ca8","name":"Lock & Engine","func":"// Declare variables\nvar number_plate = \"aplate1\";\n// Lock\nif (msg.payload.idx == \"906\") {\nmsg.topic = \"volvo/\" + number_plate + \"/lock/lock/cmd\";\nif (msg.payload.nvalue == 1) {\nmsg.payload = \"lock\";\n}else{\nmsg.payload = \"unlock\";\n}\nreturn msg;\n}\nif (msg.payload.idx == \"905\") {\nmsg.topic = \"volvo/\" + number_plate + \"/switch/is_engine_running/cmd\";\nif (msg.payload.nvalue == 1) {\nmsg.payload = \"on\";\n}else{\nmsg.payload = \"off\";\n}\nreturn msg;\n}","outputs":1,"noerr":0,"x":780,"y":120,"wires":[["f218c8c6.484ed8","5c1f2969.be8e78"]]},{"id":"f218c8c6.484ed8","type":"debug","z":"494c88d0.ac5ca8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":770,"y":180,"wires":[]},{"id":"9b500cef.3ffa4","type":"debug","z":"494c88d0.ac5ca8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":190,"y":860,"wires":[]},{"id":"1762d8fa.9239f7","type":"mqtt in","z":"494c88d0.ac5ca8","name":"MQTT-Owntracks","topic":"owntracks/volvo/aplate1","qos":"2","datatype":"auto","broker":"6fc03d79.ef77e4","x":200,"y":780,"wires":[["9b500cef.3ffa4","2eac10ca.b94af"]]},{"id":"2eac10ca.b94af","type":"json","z":"494c88d0.ac5ca8","name":"","property":"payload","action":"","pretty":true,"x":410,"y":780,"wires":[["af3d7902.773f88","f508d06f.c8d3c"]]},{"id":"af3d7902.773f88","type":"debug","z":"494c88d0.ac5ca8","name":"Json","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":370,"y":860,"wires":[]},{"id":"5c1f2969.be8e78","type":"rbe","z":"494c88d0.ac5ca8","name":"changed?","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":1020,"y":120,"wires":[["ad958743.a273a8","14521bb3.8170d4"]]},{"id":"ad958743.a273a8","type":"debug","z":"494c88d0.ac5ca8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1030,"y":180,"wires":[]},{"id":"88c07e9d.c0b4","type":"rbe","z":"494c88d0.ac5ca8","name":"changed?","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":980,"y":340,"wires":[["f75a77e4.c36508","6f7966df.8dbeb8"]]},{"id":"6f7966df.8dbeb8","type":"debug","z":"494c88d0.ac5ca8","name":"Analoge Unchanged out","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1050,"y":580,"wires":[]},{"id":"f508d06f.c8d3c","type":"filter","z":"494c88d0.ac5ca8","name":"","property":"payload._type","propertyType":"msg","asArray":false,"itemProperty":"","itemPropertyType":"item","rules":[{"t":"eq","v":"location","vt":"str","output":1}],"checkall":"true","outputs":1,"x":570,"y":780,"wires":[["16d04d4f.1613f3","1b12a286.8de45d","a2acb03b.6c449"]]},{"id":"16d04d4f.1613f3","type":"debug","z":"494c88d0.ac5ca8","name":"Filter","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":570,"y":860,"wires":[]},{"id":"e09061a6.69cce","type":"http request","z":"494c88d0.ac5ca8","name":"Http request","method":"GET","ret":"obj","paytoqs":false,"url":"","tls":"","persist":false,"proxy":"","authType":"","x":970,"y":780,"wires":[["b10eecd5.8892c","e1c71c62.8192b"]]},{"id":"1b12a286.8de45d","type":"function","z":"494c88d0.ac5ca8","name":"Prepare URL Temp","func":"var url = \"https://weather.api.here.com/weather/1. ... on\";\nvar prod = \"observation\";\nvar app_id = \"V------------------------------E\";\nvar app_code = \"M------------------------------Q\";\nvar newUrl = { url: url + \"?product=\" + prod + \"&latitude=\" + msg.payload.lat + \"&longitude=\" +\nmsg.payload.lon + \"&oneobservation=true&app_id=\" + app_id + \"&app_code=\" + app_code};\nreturn newUrl;","outputs":1,"noerr":0,"x":770,"y":780,"wires":[["e09061a6.69cce"]]},{"id":"b10eecd5.8892c","type":"function","z":"494c88d0.ac5ca8","name":"Temp","func":"msg.payload =\n{\"command\":\"udevice\",\"idx\":920,\"nvalue\":0,\"svalue\":parseFloat(msg.payload.observations.location[0].\nobservation[0].temperature).toFixed(0)};\nreturn msg;","outputs":1,"noerr":0,"x":1130,"y":780,"wires":[["20e53bfa.b81314","e4ff4be4.628ea8"]]},{"id":"6818132b.45397c","type":"debug","z":"494c88d0.ac5ca8","name":"request","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":960,"y":860,"wires":[]},{"id":"f8067de9.3f914","type":"mqtt out","z":"494c88d0.ac5ca8","name":"","topic":"domoticz/in","qos":"","retain":"","broker":"6fc03d79.ef77e4","x":1530,"y":740,"wires":[]},{"id":"20e53bfa.b81314","type":"debug","z":"494c88d0.ac5ca8","name":"temp","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1130,"y":900,"wires":[]},{"id":"e4ff4be4.628ea8","type":"rbe","z":"494c88d0.ac5ca8","name":"changed?","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":1300,"y":780,"wires":[["f8067de9.3f914","8995bf88.56429"]]},{"id":"6bf661cb.ca5d3","type":"debug","z":"494c88d0.ac5ca8","name":"Changed?","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1300,"y":860,"wires":[]},{"id":"a2acb03b.6c449","type":"function","z":"494c88d0.ac5ca8","name":"PrepareURL Location","func":"var url = \"https://reverse.geocoder.api.here.com/6 ... on\";\nvar mode = \"retrieveAddresses\";\nvar app_id = \"VYitmwS5PaBmwrY3j0yE\";\nvar app_code = \"MssIhmLd01HWIGqQ6RCEHQ\";\nvar newUrl = { url: url + \"?prox=\" + msg.payload.lat + \"%2C\" + msg.payload.lon + \"%2C\" + \"10\" +\n\"&mode=\" + mode + \"&maxresults=1&gen=9\" + \"&app_id=\" + app_id + \"&app_code=\" + app_code};\nreturn newUrl;","outputs":1,"noerr":0,"x":780,"y":740,"wires":[["d8f7feaf.9ae37"]]},{"id":"d8f7feaf.9ae37","type":"http request","z":"494c88d0.ac5ca8","name":"Http request","method":"GET","ret":"obj","paytoqs":false,"url":"","tls":"","persist":false,"proxy":"","authType":"","x":970,"y":740,"wires":[["bd893963.57fbc8","6818132b.45397c"]]},{"id":"bd893963.57fbc8","type":"function","z":"494c88d0.ac5ca8","name":"location","func":"msg.payload = {\"command\":\"udevice\",\"idx\":921,\"nvalue\":0,\"svalue\":\n(msg.payload.Response.View[0].Result[0].Location.Address.Label)};\nreturn msg","outputs":1,"noerr":0,"x":1130,"y":740,"wires":[["e219dc4a.bf6a2","f64c55cf.44e988"]]},{"id":"e219dc4a.bf6a2","type":"rbe","z":"494c88d0.ac5ca8","name":"changed?","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":1300,"y":740,"wires":[["f8067de9.3f914","6bf661cb.ca5d3"]]},{"id":"f64c55cf.44e988","type":"debug","z":"494c88d0.ac5ca8","name":"Location","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1120,"y":860,"wires":[]},{"id":"8995bf88.56429","type":"debug","z":"494c88d0.ac5ca8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1310,"y":900,"wires":[]},{"id":"e1c71c62.8192b","type":"debug","z":"494c88d0.ac5ca8","name":"Request","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":960,"y":900,"wires":[]},{"id":"6fc03d79.ef77e4","type":"mqtt-broker","z":"","name":"LocalhostMqtt","broker":"localhost","port":"1883","clientid":"testing","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]


Regards
Evert
User avatar
FireWizard
Posts: 1745
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 »

Hello Evert,

Looks good, if this is, at least, what you wanted. :D

Not every sensor is included, but that is up to every user.

I have two comments and both are regarding the position in the flow of the RBE node.
1. In the second flow, starting with MQTT-VoC-Out, I see, that you have, after the Analog Sensors function node, a RBE node, before you go to domoticz/in. Sensors in Domoticz have a time-out. This time-out, you can configure in "Setup" => "Settings" => "Other". There you will find a configuration option, called "Sensor Timeout". I have configured 7200, which means 5 days.
If you do not update a sensor before the timeout is reached, your sensor will show a red bar at the top, which is meant as a communication error.

Especially two analog sensors are likely to give such an error: Average Speed and Fuel Consumption.
You have them not configured, yet. And, of course, all sensors will give this error, if your car is not in use during this period, e.g. during holidays, if you go by plane.

I experienced that behavior myself, when I had only one function node with the analogue and binary sensors together.
Therefore I made a split.

2.In the third flow, starting with MQTT-Owntracks, you have such a RBE node after location function node.
This means that the location is requested every 5 minutes. Although you have enough credits from HERE, but in my opinion it is useless to request every 5 minutes the location for the same co-ordinates. If you move it to between the filter and "Prepare URL Location, you only ask a new address, if the co-ordinates have been changed.

Questions.

Is it by purpose you chose a counter for the odometer? As the value in now "0".
Do you have comments on the Howto document?

Regards
User avatar
sincze
Posts: 1299
Joined: Monday 02 June 2014 22:46
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: Netherlands / Breda Area
Contact:

Re: Connected Cars

Post by sincze »

Created the following for fun with Pass2PHP and GitHub help for a connected car.
domoticz-bmw.JPG
domoticz-bmw.JPG (83.93 KiB) Viewed 3444 times
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
User avatar
FireWizard
Posts: 1745
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,

The picture looks nice.

Can you tell a little bit more, as this helps other interested users, that owns a BMW.
How do you communicate?
Which help do you refer to?

Regards
User avatar
sincze
Posts: 1299
Joined: Monday 02 June 2014 22:46
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: Netherlands / Breda Area
Contact:

Re: Connected Cars

Post by sincze »

FireWizard wrote: Wednesday 01 January 2020 21:50 Hi,

The picture looks nice.

Can you tell a little bit more, as this helps other interested users, that owns a BMW.
How do you communicate?
Which help do you refer to?

Regards
Ofcourse.
I started my search at github and found a project called bimmer-connected as this is python based it can be transferred to a Domoticz Plugin. https://github.com/bimmerconnected/bimmer_connected a fellow, maybe former :D Domoticz user @gerard33 seems to be very enthousiastic about this.

Code: Select all

pi@raspberrypi:~ $ sudo apt install python3-pip
pi@raspberrypi:~ $ pip3 install bimmer-connected                                                                                                                
The script chardetect is installed in '/home/pi/.local/bin' which is not in my PATH.
Also I have Debian Buster installed so 1 extra line is needed.

Code: Select all

pi@raspberrypi:~ $ sudo sed -i "s|TLSv1.2|TLSv1.0|g" /etc/ssl/openssl.cnf
After that I was able to extract the first info.

Code: Select all

pi@raspberrypi:~ $ /home/pi/.local/bin/bimmerconnected fingerprint USERNAME PASSWORD rest_of_world
pi@raspberrypi:~ $ /home/pi/.local/bin/bimmerconnected status USERNAME PASSWORD rest_of_world
as a result.... a lot of info that can be parsed.

Code: Select all

doorDriverFront": "CLOSED",
doorDriverRear": "CLOSED",                                                                                                                                     
doorPassengerFront": "CLOSED",
doorPassengerRear": "CLOSED",                                                                                                                                  
windowDriverFront": "CLOSED",
windowDriverRear": "CLOSED",                                                                                                                                  
windowPassengerFront": "CLOSED",
windowPassengerRear": "CLOSED",         
As I work with Pass2PHP I looked for an additional quick start. I found that one:
https://github.com/bluewalk/BMWConnecteDrive, this could be easily integraded with the Pass2PHP approach and needed some lines of code to make it work.
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
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
About a year ago I ran out of time. In the mean time I sold my Volvo so my project stopt. Last februari I bought an other Volvo. And since we have plenty of time now (due to Corona) I started started again. I made a debian VM on my QNAP instead of working on a Raspberry. In this way I can make snapshots and return to a previous one if I do something wrong.
I want to massive thank you for your How-To.. pdf. It helps a lot. I'm starting to build the first Node-Red flows now. As soon as I have things running I wil post the pictures
First (again) I just wanted to thank you!!
Regards
User avatar
FireWizard
Posts: 1745
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 »

Thanks,

I look forward to see your results.

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
I am making the function node for binary sensors
Om page 14 of your How To ...pdf there is "Convert Binary Sensors to Domoticz"
This is just with one sensor. On all other binary sensors you're not usings this.

Is this text correct or a typo?
regards
Martin
MrHobbes74
Posts: 115
Joined: Sunday 19 January 2020 22:29
Target OS: Raspberry Pi / ODroid
Domoticz version: latest B
Location: Netherlands
Contact:

Re: Connected Cars

Post by MrHobbes74 »

Hi! In the latest stable of Domoticz I have created a (c++) hardware module as native support for EV's (see https://www.domoticz.com/wiki/EVehicles). The module communicates with a car through a standard API interface, and this API can be implemented for various cars. Currently only the Tesla API is implemented, but we could also add Volvo here. It does not provide all sensors you like to have, as i see from the dashboard above, but everything can be extended of course. Is this an idea?
User avatar
FireWizard
Posts: 1745
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 »

Hello Martin,

I assume you mean the first line in the function node?
// Function node for Binary Sensors

Every line, starting with // is a comment and does nothing
The complete contents of the function node is:

Code: Select all

// Function node for Binary Sensors
// Declare variables
var number_plate = "ABC123";

// Binary Sensors which will give alert

if (msg.topic == "volvo/" + number_plate + "/binary_sensor/doors_hood_open/state"){
if (msg.payload == "close") {
msg.payload = {"command":"udevice","idx":204,"nvalue":1,"svalue":"Closed"};
} else {
msg.payload = {"command":"udevice","idx":204,"nvalue":4,"svalue":"Open"};
}
return msg;
}

if (msg.topic == "volvo/" + number_plate + "/binary_sensor/doors_front_left_door_open/state"){
if (msg.payload == "close") {
msg.payload = {"command":"udevice","idx":200,"nvalue":1,"svalue":"Closed"};
} else {
msg.payload = {"command":"udevice","idx":200,"nvalue":4,"svalue":"Open"};
}
return msg;
}

if (msg.topic == "volvo/" + number_plate + "/binary_sensor/doors_front_right_door_open/state"){
if (msg.payload == "close") {
msg.payload = {"command":"udevice","idx":203,"nvalue":1,"svalue":"Closed"};
} else {
msg.payload = {"command":"udevice","idx":203,"nvalue":4,"svalue":"Open"};
}
return msg;
}

if (msg.topic == "volvo/" + number_plate + "/binary_sensor/doors_rear_left_door_open/state"){
if (msg.payload == "close") {
msg.payload = {"command":"udevice","idx":201,"nvalue":1,"svalue":"Closed"};
} else {
msg.payload = {"command":"udevice","idx":201,"nvalue":4,"svalue":"Open"};
}
return msg;
}

if (msg.topic == "volvo/" + number_plate + "/binary_sensor/doors_rear_right_door_open/state"){
if (msg.payload == "close") {
msg.payload = {"command":"udevice","idx":202,"nvalue":1,"svalue":"Closed"};
} else {
msg.payload = {"command":"udevice","idx":202,"nvalue":4,"svalue":"Open"};
}
return msg;
}

if (msg.topic == "volvo/" + number_plate + "/binary_sensor/doors_tailgate_open/state"){
if (msg.payload == "close") {
msg.payload = {"command":"udevice","idx":205,"nvalue":1,"svalue":"Closed"};
} else {
msg.payload = {"command":"udevice","idx":205,"nvalue":4,"svalue":"Open"};
}
return msg;
}

if (msg.topic == "volvo/" + number_plate + "/binary_sensor/windows_front_left_window_open/state"){
if (msg.payload == "close") {
msg.payload = {"command":"udevice","idx":196,"nvalue":1,"svalue":"Closed"};
} else {
msg.payload = {"command":"udevice","idx":196,"nvalue":4,"svalue":"Open"};
}
return msg;
}

if (msg.topic == "volvo/" + number_plate + "/binary_sensor/windows_front_right_window_open/state"){
if (msg.payload == "close") {
msg.payload = {"command":"udevice","idx":199,"nvalue":1,"svalue":"Closed"};
} else {
msg.payload = {"command":"udevice","idx":199,"nvalue":4,"svalue":"Open"};
}
return msg;
}

if (msg.topic == "volvo/" + number_plate + "/binary_sensor/windows_rear_left_window_open/state"){
if (msg.payload == "close") {
msg.payload = {"command":"udevice","idx":197,"nvalue":1,"svalue":"Closed"};
} else {
msg.payload = {"command":"udevice","idx":197,"nvalue":4,"svalue":"Open"};
}
return msg;
}

if (msg.topic == "volvo/" + number_plate + "/binary_sensor/windows_rear_right_window_open/state"){
if (msg.payload == "close") {
msg.payload = {"command":"udevice","idx":198,"nvalue":1,"svalue":"Closed"};
} else {
msg.payload = {"command":"udevice","idx":198,"nvalue":4,"svalue":"Open"};
}
return msg;
}

// Binary Sensors which will give text

if (msg.topic == "volvo/" + number_plate + "/binary_sensor/tyre_pressure_front_left_tyre_pressure/state"){
if (msg.payload == "safe") {
msg.payload = {"command":"udevice","idx":206,"nvalue":0,"svalue":"Safe"};
} else {
msg.payload = {"command":"udevice","idx":206,"nvalue":0,"svalue":"Unsafe"};
}
return msg;
}

if (msg.topic == "volvo/" + number_plate + "/binary_sensor/tyre_pressure_front_right_tyre_pressure/state"){
if (msg.payload == "safe") {
msg.payload = {"command":"udevice","idx":207,"nvalue":0,"svalue":"Safe"};
} else {
msg.payload = {"command":"udevice","idx":207,"nvalue":0,"svalue":"Unsafe"};
}
return msg;
}

if (msg.topic == "volvo/" + number_plate + "/binary_sensor/tyre_pressure_rear_left_tyre_pressure/state"){
if (msg.payload == "safe") {
msg.payload = {"command":"udevice","idx":208,"nvalue":0,"svalue":"Safe"};
} else {
msg.payload = {"command":"udevice","idx":208,"nvalue":0,"svalue":"Unsafe"};
}
return msg;
}

if (msg.topic == "volvo/" + number_plate + "/binary_sensor/tyre_pressure_rear_right_tyre_pressure/state"){
if (msg.payload == "safe") {
msg.payload = {"command":"udevice","idx":209,"nvalue":0,"svalue":"Safe"};
} else {
msg.payload = {"command":"udevice","idx":209,"nvalue":0,"svalue":"Unsafe"};
}
return msg;
}

if (msg.topic == "volvo/" + number_plate + "/binary_sensor/washer_fluid_level/state"){
if (msg.payload == "safe") {
msg.payload = {"command":"udevice","idx":218,"nvalue":0,"svalue":"Safe"};
} else {
msg.payload = {"command":"udevice","idx":218,"nvalue":0,"svalue":"Unsafe"};
}
return msg;
}

if (msg.topic == "volvo/" + number_plate + "/binary_sensor/brake_fluid/state"){
if (msg.payload == "safe") {
msg.payload = {"command":"udevice","idx":217,"nvalue":0,"svalue":"Safe"};
} else {
msg.payload = {"command":"udevice","idx":217,"nvalue":0,"svalue":"Unsafe"};
}
return msg;
}

if (msg.topic == "volvo/" + number_plate + "/binary_sensor/service_warning_status/state"){
if (msg.payload == "safe") {
msg.payload = {"command":"udevice","idx":224,"nvalue":0,"svalue":"Safe"};
} else {
msg.payload = {"command":"udevice","idx":224,"nvalue":0,"svalue":"Unsafe"};
}
return msg;
}

if (msg.topic == "volvo/" + number_plate + "/binary_sensor/bulb_failures/state"){
if (msg.payload == "safe") {
msg.payload = {"command":"udevice","idx":226,"nvalue":0,"svalue":"Safe"};
} else {
msg.payload = {"command":"udevice","idx":226,"nvalue":0,"svalue":"Unsafe"};
}
return msg;
}

// Binary Sensors not in use

//if (msg.topic == "volvo/" + number_plate + "/binary_sensor/any_door_open/state"){
//if (msg.payload == "close") {
//msg.payload = {"command":"udevice","idx":xxx,"nvalue":1,"svalue":"Closed"};
//} else {
//msg.payload = {"command":"udevice","idx":xxx,"nvalue":4,"svalue":"Open"};
//}
//return msg;
//}

//if (msg.topic == "volvo/" + number_plate + "/binary_sensor/any_window_open/state"){
//if (msg.payload == "close") {
//msg.payload = {"command":"udevice","idx":yyy,"nvalue":1,"svalue":"Closed"};
//} else {
//msg.payload = {"command":"udevice","idx":yyy,"nvalue":4,"svalue":"Open"};
//}
//return msg;
//}

if (msg.topic == "volvo/" + number_plate + "/binary_sensor/is_engine_running/state"){
if (msg.payload == "off") {
msg.payload = {"command":"udevice","idx":230,"nvalue":0,"svalue":"Off"};
} else {
msg.payload = {"command":"udevice","idx":230,"nvalue":0,"svalue":"On"};
}
return msg;
}

if (msg.topic == "volvo/" + number_plate + "/lock/lock/state"){
if (msg.payload == "lock") {
msg.payload = {"command":"udevice","idx":228,"nvalue":0,"svalue":"Locked"};
} else {
msg.payload = {"command":"udevice","idx":228,"nvalue":0,"svalue":"Unlocked"};
}
return msg;
}

if (msg.topic == "volvo/" + number_plate + "/switch/heater/state"){
if (msg.payload == "off") {
msg.payload = {"command":"udevice","idx":229,"nvalue":0,"svalue":"Off"};
} else {
msg.payload = {"command":"udevice","idx":229,"nvalue":0,"svalue":"On"};
}
return msg;
}

if (msg.topic == "volvo/" + number_plate + "/sensor/trips/state"){
msg.payload = {"command":"udevice","idx":227,"nvalue":0,"svalue":(msg.payload)};
return msg;
}
Perhaps, you can use it, but you have to replace the idx's for your idx's.
And change ABC123 with your number plate.

Regards
MrHobbes74
Posts: 115
Joined: Sunday 19 January 2020 22:29
Target OS: Raspberry Pi / ODroid
Domoticz version: latest B
Location: Netherlands
Contact:

Re: Connected Cars

Post by MrHobbes74 »

MrHobbes74 wrote: Sunday 29 March 2020 22:44 Hi! In the latest stable of Domoticz I have created a (c++) hardware module as native support for EV's (see https://www.domoticz.com/wiki/EVehicles). The module communicates with a car through a standard API interface, and this API can be implemented for various cars. Currently only the Tesla API is implemented, but we could also add Volvo here. It does not provide all sensors you like to have, as i see from the dashboard above, but everything can be extended of course. Is this an idea?
Never mind ;-), I now notice the Volvo mentioned is not an EV, but a petrol car API. That will not fit the EV framework (for starting/stopping charging).
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,

I mean this part (see screenshot)

regards
Attachments
screenshot
screenshot
plaatje.jpg (44.24 KiB) Viewed 3280 times
User avatar
FireWizard
Posts: 1745
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 »

:o
Hello Martin,

I see it.
It must accidently have been pasted in the document. I shall correct it later.
Use the posted flow. You will see, it is not there.

Thanks for reporting

Regards.

[Edit] Document has been corrected and the corrected version has been uploaded to github.
User avatar
FireWizard
Posts: 1745
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 »

Hello
@MrHobbes74

Thanks for your reaction.
I have followed your "Tesla" project with very much of interest. And it is great, that it is natively included in Domoticz hardware.
When I saw that, I thought would be nice to have this for Volvo on Call as well.

I started this thread about a year ago, when I discovered that it was possible to integrate Volvo on Call in Home Assistant.
And OpenHab use it as well. I thought that, what is possible in HA and others, should also be possible in Domoticz.
When I started this thread, there was nothing on this forum, discussing so called "Connected Cars".
All solution mentioned uses a python script, reversed engineered, by "molobrakos". See: https://github.com/molobrakos/volvooncall.

I think it is a little bit of a "grey" area. Reverse engineering is forbidden in Swedish law (They call it: datatrepassing). That was not what I did, I found the script and use it. I'm not a C++ programmer. So I used the way, as there is MQTT support in the script, using this and convert it in Node Red and so to Domoticz. Indeed I did not implement the sensors for Electrical Volvo's, as I do not own an EV, but still a petrol car.

My car indicates: "highVoltageBatterySupported": false, so I do not have the EV sensors.

However I know the following exist, at least
hvBattery distanceToHVBatteryEmpty
hvBattery distanceToHVBatteryEmptyTimestamp
hvBattery hvBatteryChargeModeStatus
hvBattery hvBatteryChargeStatus
hvBattery hvBatteryChargeStatusDerived
hvBattery hvBatteryChargeWarning
hvBattery hvBatteryLevel
hvBattery timeToHVBatteryFullyChargedTimestamp
If you think, you can implement Volvo on Call, I'm happy to support you in testing, etc.

Regards
Last edited by FireWizard on Monday 20 July 2020 20:37, edited 1 time in total.
WvdM78
Posts: 9
Joined: Wednesday 01 April 2020 14:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.1
Location: The Netherlands
Contact:

Re: Connected Cars

Post by WvdM78 »

MrHobbes74 wrote: Sunday 29 March 2020 22:44 Hi! In the latest stable of Domoticz I have created a (c++) hardware module as native support for EV's (see https://www.domoticz.com/wiki/EVehicles). The module communicates with a car through a standard API interface, and this API can be implemented for various cars. Currently only the Tesla API is implemented, but we could also add Volvo here. It does not provide all sensors you like to have, as i see from the dashboard above, but everything can be extended of course. Is this an idea?
I am planning to try to connect my BMW i3 EV to Domoticz so I can log the total km driven and to stop charging at a specified state of charge.
Is it possible to include the BMW API communication as well into Domoticz?
User avatar
sincze
Posts: 1299
Joined: Monday 02 June 2014 22:46
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: Netherlands / Breda Area
Contact:

Re: Connected Cars

Post by sincze »

WvdM78 wrote: Wednesday 01 April 2020 14:52
MrHobbes74 wrote: Sunday 29 March 2020 22:44 Hi! In the latest stable of Domoticz I have created a (c++) hardware module as native support for EV's (see https://www.domoticz.com/wiki/EVehicles). The module communicates with a car through a standard API interface, and this API can be implemented for various cars. Currently only the Tesla API is implemented, but we could also add Volvo here. It does not provide all sensors you like to have, as i see from the dashboard above, but everything can be extended of course. Is this an idea?
I am planning to try to connect my BMW i3 EV to Domoticz so I can log the total km driven and to stop charging at a specified state of charge.
Is it possible to include the BMW API communication as well into Domoticz?
Well we could have a look at it as your i3 has BMW-Connected and the data is available.

Image
bmw.png
bmw.png (24.6 KiB) Viewed 3256 times
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
astrapowerrr
Posts: 141
Joined: Tuesday 31 January 2017 20:34
Target OS: -
Domoticz version:
Contact:

Re: Connected Cars

Post by astrapowerrr »

Hmmm bmw i3 owner... im interested!!
User avatar
sincze
Posts: 1299
Joined: Monday 02 June 2014 22:46
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: Netherlands / Breda Area
Contact:

Re: Connected Cars

Post by sincze »

astrapowerrr wrote: Tuesday 14 April 2020 22:16 Hmmm bmw i3 owner... im interested!!
It could be based upon bimmer_connected:
https://github.com/bimmerconnected/bimmer_connected

Code: Select all

# get the latest version of the library
pip3 install --upgrade bimmer_connected

# run the fingerprint function
bimmerconnected fingerprint <username> <password> <region>
Now the trick would be to write a plugin that executes and retrieves the json for parsing.
Other Solution: My solution works with Pass2PHP. I could try to modify the module so you can work with that? Pass2PHP means PHP is required on your system.
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
Geitje
Posts: 170
Joined: Monday 22 January 2018 21:52
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Connected Cars

Post by Geitje »

Really cool this development! It is that I do not own a connected car, otherwise I would certainly have tried it...
Domoticz beta, on Raspberry Pi 3B, Raspian Buster
Zwave, Zigate, RFlink etc.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest