[RELEASE] Volvo On Call (VOC)

This is my first attempt at a Hubitat driver, my coding skills are somewhat rusty, so please feel free to offer any advice on improvements to the code or the interaction with Hubitat.

This is a driver to support the Volvo On Call API. It provides all of the car attributes, many of which are not available in the Volvo app.

Commands include Lock, Unlock, Pre-climatization, Blink Lights and Sound Horn.
Also uses the car location to work as a presence device.

The driver configuration will need the VOC login details and the car VIN (available in the VOC app), which must have a valid subscription to the VOC service. The region parameter can be left empty for UK, but I believe that it should be set to 'na' for the USA. I'm in the UK and so have been unable to test for any other region.

Let me know if anyone can give it a try, as I'd be interested to get some feedback.

https://github.com/andrew0x01/hubitat/blob/master/drivers/VOC/Volvo-On-Call.groovy

9 Likes

I don't have a Volvo but I wish now to have one. Thanks for the contribution.

This is cool.

I’m in the US and it seems to connect to my car. It knows the status of the various attributes, including the car’s location.

But sending an unlock command doesn’t seem to work. Here is a shot of the hub log, any thoughts?

Thanks for the feedback, good to know that it could be useful to someone. This driver just started as something to get me coding on Hubitat (I'm a new owner) and then I decided to try and get it working.

The Unlock command is interesting, as it appears that Volvo have changed its operation since I started using the VOC app with the car a few years ago. I'm sure I remember that when using the VOC app in the past the unlock just flashed the lights and unlocked all the doors, just the same as using the key fob.

Now, if I use the VOC app to unlock the doors, there's no light flash and the app just says "Boot unlocked". The VOC support site instructs you to "press once gently on the rubberised pressure plate underneath the boot lid handle to unlock the car", which then unlocks all of the doors. (You have to do this within a reasonable period of time).

So, for my Hubitat driver, the Unlock command is the same, you don't get any visual sign from the car and you then have to "press once gently on the rubberised pressure plate underneath the boot lid handle to unlock the car". I guess it's just to improve the security for this operation.

Hope this helps, let me know if it works for you.

This is very cool! One suggestion would be to require a pin/password for start and unlock.

This is nice, will try it right away!
Have to Volvo's XC40 and v40, both with VOC enabled so this will definitely come in handy :smile:

Hrms, get this error when trying. Can't see that i'am doing something wrong and have correct values as username, password and vin. Also no region as i'am in Europe ?


[dev:393](http://10.0.0.70/logs#dev393)2019-04-14 20:56:21.584 [error](http://10.0.0.70/device/edit/393)httpGet call failed for VOC api: groovyx.net.http.HttpResponseException: Unauthorized

[dev:393](http://10.0.0.70/logs#dev393)2019-04-14 20:56:21.307 [info](http://10.0.0.70/device/edit/393)Volvo on Call XC40 getting position

[dev:393](http://10.0.0.70/logs#dev393)2019-04-14 20:56:21.304 [warn](http://10.0.0.70/device/edit/393)No response from VOC API

[dev:393](http://10.0.0.70/logs#dev393)2019-04-14 20:56:21.302 [error](http://10.0.0.70/device/edit/393)httpGet call failed for VOC api: groovyx.net.http.HttpResponseException: Unauthorized

[dev:393](http://10.0.0.70/logs#dev393)2019-04-14 20:56:20.982 [info](http://10.0.0.70/device/edit/393)Volvo on Call XC40 getting status

[dev:393](http://10.0.0.70/logs#dev393)2019-04-14 20:56:20.980 [info](http://10.0.0.70/device/edit/393)Volvo on Call XC40 executing poll

[dev:393](http://10.0.0.70/logs#dev393)2019-04-14 20:56:20.977 [debug](http://10.0.0.70/device/edit/393)updated()

also when trying to add a Virtual Device and press save with these driver a get error 500. Device is getting added but this error occurred. Have unique identifiers and names so that should not be a problem. Using latest available Hubitat firmware 2.0.8.113.

Error 500

A Server error has occurred

If you are seeing this screen repeatedly, please contact Support. For assistance, email support@hubitat.com or go to community.hubitat.com.

This just looks like an authorisation issue. Are you able to use the Volvo VOC app with the same identification details and VIN number?

I've just updated to the latest HE firmware and don't have any problems.

Hi! Thanks for your reply :smile:

Yes, using it on two phones and it works great. I tried now when you said it probably is a authorisation issue to copy/paste vin from app directly. Ofcource it worked directly so probably was a typo, 0 and O mixed maybe in vin. So you was absolutely right :blush:

I get all values except one, shows this error in log.

dev:3932019-04-15 22:17:56.528 errorjava.lang.NullPointerException: Cannot get property 'hvBatteryChargeStatusDerived' on null object on line 361 (updated) 

Ok, good.

I don’t receive that error, so it must be related to the data available for your particular vehicle.

I’ll take a look at the code and get back to you, but it won’t be today.

Thanks for giving it a try, it’s good for me to know that it’s of interest.

1 Like

Thank you, great work on this. Very appreciated. :grinning::ok_hand:

@Andrew1
Updated the driver because it halted on the error in my previous post. I get these error on both my car's, (xc40 -2019 and v40-2018). So not all info was parsed and had to commenting out below code to make it work again.

// sendEvent(name: "hvBatteryChargeStatusDerived", value: obs.hvBattery.hvBatteryChargeStatusDerived, displayed: false)
	// sendEvent(name: "hvBatteryChargeModeStatus", value: obs.hvBattery.hvBatteryChargeModeStatus, displayed: true)
	// sendEvent(name: "hvBatteryChargeStatus", value: obs.hvBattery.hvBatteryChargeStatus, displayed: true)
	// sendEvent(name: "hvBatteryLevel", value: obs.hvBattery.hvBatteryLevel, displayed: true)
	// sendEvent(name: "distanceToHVBatteryEmpty", value: obs.hvBattery.distanceToHVBatteryEmpty, displayed: true)
	// sendEvent(name: "hvBatteryChargeWarning", value: obs.hvBattery.hvBatteryChargeWarning, displayed: true)
	// sendEvent(name: "timeToHVBatteryFullyCharged", value: obs.hvBattery.timeToHVBatteryFullyCharged, displayed: true)

I wanted a direct link to google maps to quickly see where the cars position is and also wanted a second state for the position's values in this format (lat, long) for easy logging to a external db and be able to plotter it as a route where the car have been on a external web page. So added this to the code

		attribute "positions", "number"
		attribute "GMaps Link", "string"

	def sendThis = "${obs.position.latitude}, ${obs.position.longitude}"
	def sendThis2 = "<a href=\"https://www.google.com/maps/search/?api=1&query=${obs.position.latitude},${obs.position.longitude}\" target=\"_blank\">${obs.position.latitude},${obs.position.longitude}</a>"

	sendEvent(name: "positions", value: sendThis, displayed: true)
	sendEvent(name: "GMaps Link", value: sendThis2, displayed: true)

	log.info "${obs.position.latitude}, ${obs.position.longitude}"
	log.info "<a href=\"https://www.google.com/maps/search/?api=1&query=${obs.position.latitude},${obs.position.longitude}\" target=\"_blank\">${obs.position.latitude},${obs.position.longitude}</a>"

Again, big thanks for the great work on this driver, love it! =)

Updated to v1.0.1 which checks JSON response for HvBattery as this is not returned for non hybrid vehicles and includes new attributes for "latitude,longitude" and URL to google maps. Thanks to chrbratt for these suggestions.

This is awesome!!

I just switched to HE from Wink this past weekend, so was excited to see this.

I hope you don;t mind, but I made a few changes.

  1. I added the ability to start/stop the engine.
  2. I renamed a few of the commands to better suit my needs (lock to door lock, etc)
  3. I added the option to convert the status data to Imperial.
3 Likes

Once again, Welcome to the Hubitat Community!

Volvo exposed the ability to start and stop the engine to the internet?! :astonished:

Yep. This driver basically pretends it's the mobile app. Was just a matter of intercepting the Apps outbound traffic to see what happened when I pressed the "Start Engine" button in the app, then adding that to the splendid framework that Andrew1 created.

1 Like

P.S. I added an actuator capability so that the functions can be called from RM. I'm working on tiles as well. This is all new to me, so might be a bit. It's fun to learn.

Now Hubitat locks the car if I forget, as part of my bedtime routine, and I can slap the Fibaro "easy button" to start the engine in the morning.

1 Like

That part I would love. Stopping the engine? Not so much. I do hope they don’t allow this when the car is in gear. Imagine where a vehicle engine could be disabled by a remote attack! :anguished:

1 Like

I don't think that could happen through the API. I can certainly test it :stuck_out_tongue:

2 Likes

Turns out you can't do jack via the API if the key is in the car. So no worries about getting hijacked while driving down the road, or even when sitting in the car with the fob in your pocket.

1 Like