Giter VIP home page Giter VIP logo

volvooncall's Introduction

Volvo On Call

CI

Retrieve statistics about your Volvo from the Volvo On Call (VOC) online service No licence, public domain, no guarantees, feel free to use for anything. Please contribute improvements/bugfixes etc.

Also contains an MQTT gateway for publishing information and bidirectional communication with e.g. Home Assistant.

system requirements

  • At least python 3.10 or higher

For contributors: The pytype project does not yet support Python 3.11, so you must use 3.10 to run tests locally.

dependencies

To use just the API in volvooncall.py or the Home Assistant bindings in dashboard.py, simply install the package as usual with pip:

pip install volvooncall

To use console features (i.e. the voc command documented below):

pip install volvooncall[console]

To use MQTT features:

pip install volvooncall[mqtt]

how to use

> voc --help
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
  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] call <method>
  voc [-v|-vv] [options] mqtt

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
  -v,-vv                Increase verbosity
  --scandinavian_miles  Report using Scandinavian miles instead of km ISO unit
  --usa_units           Report using USA units (miles, mph, mpg, gal, etc.)
  --version             Show version

Retrieving basic status:

> voc status
ABC123 (XC60/2014) ABCD1234567890 92891km (fuel 25% 210km)
    position: 12.34567890,12.34567890
    locked: yes
    heater: off

Printing raw properties:

> voc print windows.frontLeftWindowOpen
False
./voc print fuelAmount
45

Printing some relevant iofo:

> voc dashboard
ABC123 Door lock: Locked
ABC123 Heater: Off
ABC123 Odometer: 12792 mil
ABC123 Fuel amount: 32 L
...

Periodically polling the VOC server and republishing all information to a MQTT server

> voc mqtt

Configuration file in $HOME/.voc.conf:

username: <username>
password: <password>

credits

https://web.archive.org/web/20180817103553/https://paulpeelen.com/2013/02/08/volvo-on-call-voc-api/ and a lot of random contributors

volvooncall's People

Contributors

austinmroczek avatar decompil3d avatar fabaff avatar ivanfmartinez avatar lobeck avatar molobrakos avatar myhrmans avatar phlantin avatar propyless avatar stefanodesjo avatar tenfire avatar timdebruijn avatar umgfoin avatar y34hbuddy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

volvooncall's Issues

SyntaxError

I got this Syntax error:

/opt/volvooncall$ ./voc
File "./voc", line 226
print(f'{instrument}: {instrument.str_state}')
^
SyntaxError: invalid syntax

Add Support for separating Honk and Blink commands

On the 2017 XC90 T8, within the App, I'm able to flash the lights, or do both the Horn and Flash... Pulling the status from your script, I noticed this:

 "honkAndBlinkDistance": 500,
"honkAndBlinkSupported": true,
"honkAndBlinkVersionsSupported": [
    "honkAndOrBlink",
    "honkAndBlink"
],

It looks like the honkandblink supported needs to be adjusted to support the separate commands? I don't know if I have time to fork and modify and submit, but, just wanted to bring up the breakout for the honk and blink.

From here: https://forums.swedespeed.com/showthread.php?526450-Getting-acclimated-with-VOC-API-WOW-so-much-potential! it looks like the following commands were found:

/honk_and_flash
/honk_blink/both
/honk_blink/horn
/honk_blink/lights

Here's the full Status Dump in case there's any difference between what you've seen/written for, and what might be available now:

{
"ERS": {
"status": "off",
"timestamp": "2018-06-27T16:24:12+00:00",
"engineStartWarning": "None",
"engineStartWarningTimestamp": "2018-06-27T16:24:12+00:00"
},
"VIN": "REMOVED",
"assistanceCallSupported": true,
"averageFuelConsumption": 58.0,
"averageFuelConsumptionTimestamp": "2018-07-03T17:10:11+00:00",
"averageSpeed": 41,
"averageSpeedTimestamp": "2018-07-03T17:10:11+00:00",
"bCallAssistanceNumber": "+18553994691",
"brakeFluid": "Normal",
"brakeFluidTimestamp": "2018-07-03T17:10:11+00:00",
"bulbFailures": [],
"bulbFailuresTimestamp": "2018-07-03T17:10:11+00:00",
"calculatedPosition": {
"longitude": null,
"latitude": null,
"timestamp": null,
"speed": null,
"heading": null
},
"carLocatorDistance": 1000,
"carLocatorSupported": true,
"carLocked": true,
"carLockedTimestamp": "2018-07-03T17:10:11+00:00",
"climatizationCalendarMaxTimers": 8,
"climatizationCalendarVersionsSupported": [
"climatizationCalendarV1"
],
"connectionStatus": "ConnectedWithPower",
"connectionStatusTimestamp": "2018-07-03T20:47:08+00:00",
"country": {
"iso2": "US"
},
"distanceToEmpty": 96,
"distanceToEmptyTimestamp": "2018-07-03T17:10:11+00:00",
"doors": {
"tailgateOpen": false,
"rearRightDoorOpen": false,
"rearLeftDoorOpen": false,
"frontRightDoorOpen": false,
"frontLeftDoorOpen": false,
"hoodOpen": false,
"timestamp": "2018-07-03T17:10:11+00:00"
},
"engineCode": "XXXXXXXX",
"engineRunning": false,
"engineRunningTimestamp": "2018-07-03T17:10:11+00:00",
"engineStartSupported": true,
"exteriorCode": "XXXXXXXX",
"fuelAmount": 16,
"fuelAmountLevel": 32,
"fuelAmountLevelTimestamp": "2018-07-03T17:10:11+00:00",
"fuelAmountTimestamp": "2018-07-03T17:10:11+00:00",
"fuelTankVolume": 50,
"fuelType": "HEV",
"gearboxCode": "XXXXXXXX",
"grossWeight": 3010,
"heater": {
"seatSelection": {
"frontDriverSide": false,
"frontPassengerSide": false,
"rearDriverSide": false,
"rearPassengerSide": false,
"rearMid": false
},
"status": "off",
"timer1": {
"time": null,
"state": null
},
"timer2": {
"time": null,
"state": null
},
"timestamp": "2018-06-12T01:42:34+00:00"
},
"highVoltageBatterySupported": true,
"honkAndBlinkDistance": 500,
"honkAndBlinkSupported": true,
"honkAndBlinkVersionsSupported": [
"honkAndOrBlink",
"honkAndBlink"
],
"hvBattery": {
"hvBatteryChargeStatusDerived": "CablePluggedInCar_FullyCharged",
"hvBatteryChargeStatusDerivedTimestamp": "2018-07-03T20:47:08+00:00",
"hvBatteryChargeModeStatus": null,
"hvBatteryChargeModeStatusTimestamp": null,
"hvBatteryChargeStatus": "ChargeEnd",
"hvBatteryChargeStatusTimestamp": "2018-07-03T20:47:08+00:00",
"hvBatteryLevel": 100,
"hvBatteryLevelTimestamp": "2018-07-03T20:47:08+00:00",
"distanceToHVBatteryEmpty": 29,
"distanceToHVBatteryEmptyTimestamp": "2018-07-03T20:47:08+00:00",
"hvBatteryChargeWarning": "UnexpectedPowerloss",
"hvBatteryChargeWarningTimestamp": "2018-07-03T17:32:55+00:00",
"timeToHVBatteryFullyCharged": 0,
"timeToHVBatteryFullyChargedTimestamp": "2018-07-03T20:47:08+00:00"
},
"interiorCode": "XXXXXXXX",
"journalLogEnabled": true,
"journalLogSupported": true,
"lockSupported": true,
"maxActiveDelayChargingLocations": 7,
"modelYear": 2017,
"numberOfDoors": 5,
"odometer": 10940972,
"odometerTimestamp": "2018-07-03T17:10:11+00:00",
"overrideDelayChargingSupported": false,
"position": {
"longitude": REMOVED,
"latitude": REMOVED,
"timestamp": "2018-07-03T17:09:11+00:00",
"speed": null,
"heading": null
},
"preclimatizationSupported": true,
"privacyPolicyEnabled": false,
"privacyPolicyEnabledTimestamp": "2018-02-16T21:03:14+00:00",
"registrationNumber": "UNKNOWN",
"remoteClimatizationStatus": "CableConnectedWithPower",
"remoteClimatizationStatusTimestamp": "2018-07-03T20:47:08+00:00",
"remoteHeaterSupported": false,
"sendPOIToVehicleVersionsSupported": [
"sendSinglePOIToVehicle"
],
"serverVersion": "4.18.15-voc-deployable",
"serviceWarningStatus": "Normal",
"serviceWarningStatusTimestamp": "2018-07-03T17:10:11+00:00",
"status.parkedIndoor.supported": false,
"subscriptionEndDate": "2020-09-23T12:00:00+00:00",
"subscriptionStartDate": "2017-09-23T12:00:00+00:00",
"subscriptionType": "PREMIUM_2013",
"theftAlarm": null,
"timeFullyAccessible": 7200,
"timeFullyAccessibleUntil": "2018-07-08T17:08:43+00:00",
"timePartiallyAccessible": 31680,
"timePartiallyAccessibleUntil": "2018-07-25T17:08:43+00:00",
"tripMeter1": 525400,
"tripMeter1Timestamp": "2018-07-03T17:10:11+00:00",
"tripMeter2": 5100,
"tripMeter2Timestamp": "2018-07-03T17:10:11+00:00",
"tyreDimensionCode": "XXXXXXXX",
"tyreInflationPressureHeavyCode": null,
"tyreInflationPressureLightCode": null,
"tyrePressure": {
"frontLeftTyrePressure": "Normal",
"frontRightTyrePressure": "Normal",
"rearLeftTyrePressure": "Normal",
"rearRightTyrePressure": "Normal",
"timestamp": "2018-07-03T17:10:11+00:00"
},
"unlockSupported": true,
"unlockTimeFrame": 120,
"vehiclePlatform": "XXXX",
"vehicleType": "XC90",
"vehicleTypeCode": "XXXXXXXX",
"verificationTimeFrame": 120,
"vin": "REMOVED",
"washerFluidLevel": "Normal",
"washerFluidLevelTimestamp": "2018-07-03T17:10:11+00:00",
"windows": {
"frontLeftWindowOpen": false,
"frontRightWindowOpen": false,
"timestamp": "2018-07-03T17:10:11+00:00",
"rearLeftWindowOpen": false,
"rearRightWindowOpen": false
}
}

problem with userbame and password

Hi!
totally new in this Linux programming
I got a problem when typing "voc list". I got a message "missing configuration: unit() missing 2 required arguments "username" and "password.
I have done sudo nano /.voc.conf and typed my username and password.

What do i do wrong! Wont my Volvo Xc90 T8 in Magic Mirror :)

timezone support possible for trips?

The JSON for timestamps is UTC (without timezone).
E.g.
"startTime": "2018-07-16T14:52:26+00:00", (14:52 UTC)
instead of (in my case)
"startTime": "2018-07-16T16:52:26+02:00" (16:52 CEST)

Does the API return timestamps with timezone? If so, can it be included in the output?

401 error

Hi, Iโ€™m quite new with this.

This is all I get when I try to connect

19-01-26 09:09.20 WARNING (MainThread) [volvooncall.volvooncall] Failure when communcating with the server: 401, message='Unauthorized'

Engine support in Home Assistant

Hi, would you be able to update home assistant to volvooncall:0.5.0 and add a start/stop engine switch as well?

This is the feature I use the most frequently in the VOC-app, it would really be great if we had this in home assistant as well.

mqtt

How do i use the owntracks and mqtt function?

XC40 P8 2021 support

Do you know if this library will work with XC40 P8 2021 model? When I tested the library I just get the message '401, Unauthorized'.

Add support for additional (nested) VOC resources

Hi Erik!

I hope you don't mind my reaching out directly to you. I would like to add some additional resources to the VOC app and contribute back the changes. I was wondering if you could provide some tips/hints on a particular problem. I have determined that I can add lines to the resources section (~ line 49) in the file: /components/volvooncall.py and have the new resources show up in HA. I can find the available resources by turning up logging. For example, I can see 'tripMeter1': 4086900 ... so adding trip_meter1 in the file successfully adds it to my HA states. However, on occasion, information is wrapped in an additional, 2nd level of formatting. For example, see below how information about 'tyrePressure' is formatted. As a result, if I add 'tyre_pressure' as a resource, the returned value is everything within {}. Is there an easy way to parse a sensor within the {} ... perhaps like I've seen in AWS MQTT like 'tyre_pressure.front_left_tyre_pressure' ?

Thanks for any insights you might be able to offer!
John

2017-09-12 21:52:49 DEBUG (SyncWorker_36) [volvooncall] State: {'https://vocapi-na.wirelesscar.net/customerapi/rest/v3.0/vehicles/my_vin_number/':

{'engineCode': '2421CF0B', 'tripMeter1': 4086900, 'averageFuelConsumption': 61.0,

... lots of other info ...

'tyrePressure': {'frontLeftTyrePressure': 'Normal', 'frontRightTyrePressure': 'Normal', 'rearLeftTyrePressure': 'Normal', 'rearRightTyrePressure': 'Normal', 'timestamp': datetime.datetime(2017, 9, 12, 21, 42, 25, tzinfo=datetime.timezone.utc)},

...

MQTT configuration + request for DockerHub repo

I'd like to use volvooncall and MQTT publishing to my MQTT broker. I have set up a Docker container but it looks like that a mqtt config file is missing. Could anybody help me out to find out:

  1. where to put this config file?
  2. an example of how this config file should look like?
    In this repo I do not find any information about mqtt requirements

Even better would be if a complete Docker repo would be published on DockerHub. This would make it much easier for people to use volooncall.

Thanks in advance!

Loading credentials from yaml file doesn't seem to work

When I create a new ".credentials.yaml" file based on the ".credentials.template.yaml" with my credentials in it, it doesn't work (the ImportError is caught; that's why I added the additional Logger line). Adding them from command line works fine...

Regards,

Nika.

Door lock displays incorrectly

The door lock sensor displays as unlocked when it is locked. It also seems to automatically revert back to unlocked a few minutes after it is set to locked.

Trigger command with mosquitto_pub

I'm trying to figure out how to trigger a command with mosquitto_pub.
I have tried to run mosquitto_pub -t "volvo/<REG_NR>/heater/cmd" -m "{'on': true}"
If I run voc with ./voc mqtt -vv and the run the mosquitto_pub command I get en error

Exception in thread MQTTThread:
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/usr/local/lib/python3.6/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.6/site-packages/paho/mqtt/client.py", line 2913, in _thread_main
    self.loop_forever(retry_first_connection=True)
  File "/usr/local/lib/python3.6/site-packages/paho/mqtt/client.py", line 1578, in loop_forever
    rc = self.loop(timeout, max_packets)
  File "/usr/local/lib/python3.6/site-packages/paho/mqtt/client.py", line 1072, in loop
    rc = self.loop_read(max_packets)
  File "/usr/local/lib/python3.6/site-packages/paho/mqtt/client.py", line 1374, in loop_read
    rc = self._packet_read()
  File "/usr/local/lib/python3.6/site-packages/paho/mqtt/client.py", line 2071, in _packet_read
    rc = self._packet_handle()
  File "/usr/local/lib/python3.6/site-packages/paho/mqtt/client.py", line 2560, in _packet_handle
    return self._handle_publish()
  File "/usr/local/lib/python3.6/site-packages/paho/mqtt/client.py", line 2759, in _handle_publish
    self._handle_on_message(message)
  File "/usr/local/lib/python3.6/site-packages/paho/mqtt/client.py", line 2902, in _handle_on_message
    callback(self, self._userdata, message)
TypeError: on_mqtt_message() takes 3 positional arguments but 4 were given

So I'm guessing I'm doing something wrong with the publish command. I can not seem to find any documentation around this and hoping it's OK to ask questions here.

Request: add command line option for sending commands

I have tried getting command line options to work, but just failed due the lack of my python knowledge. Can you add a command line option to customize the command sent?

The "preclimatization/start" post query, should be a variable that is parsed from command line option 3.

The response of the query (like "Status" = "Started") are added to the results. A post however also returns a response with the new service URL which can be used to see whether the message is delivered to the car (Status = MessageDelivered) and whether it was successfull (Status = Successfull).

That could be added too to the script, but as I hate that it takes so long in the app anyway, I don't really mind not doing it :) ...

'voc print remoteHeaterSupported' return "False" when heater is on

Hi,

Having trouble with $ voc print remoteHeaterSupported that returns False even though my heater is on.
The heater starts in the car when I do voc heater start.
voc status displays Heater: on

voc print heater do not give me a True or False return.

Its a V60 2019 with diesel heater if that make sense.

Heated Seat

Is there a way to specifically ask the heated seats to come on on a XC90 T8?

They don't seem to come on when asking 'voc heater start'

Thanks for a great utility!

Here is the relevant bit from 'voc print'

"heater": {
"seatSelection": {
"frontDriverSide": false,
"frontPassengerSide": false,
"rearDriverSide": false,
"rearPassengerSide": false,
"rearMid": false
},
"status": "off",
"timer1": {
"time": null,
"state": null
},
"timer2": {
"time": null,
"state": null
},

voc mqtt communication with mosquitto broker.

When trying to publish to a mosquitto broker, login to broker fails.
After trying out several options in the mosquitto_pub configuration file, it looks that
mqtt.py requires secure communication to the broker and it looks also that this function only works with Home Assistant. However https://github.com/arins/voc-to-mqtt works fine, but is not complete and no activity for over a year.
As all the other voc options works fine I would like to swith to native voc mqtt.
Current setup is with latest raspbian and python 3.7.1 on a raspberry pi.
Can this be confirmed? And if so are there easy possibilities to modify the mqtt.py file so that it will work with any broker with and without encryption.

Thanks for an answer in advance

FireWizard52

Temperature

I would love to be able to see my temp from my HA. Do you think this would be implementable?

Start Car

I can start my Car with the app, is this possible with VOC?

VoC option honk_and_blink

I tested all options, after mqtt issue has been solved and discovered the following when:

pi@rpi3plus:~/.local/bin $ voc honk_and_blink
/home/pi/.local/lib/python3.7/site-packages/volvooncall/volvooncall.py:355: RuntimeWarning: coroutine 'Vehicle.call' was never awaited
self.call("honkAndBlink")
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Traceback (most recent call last):
File "/home/pi/.local/bin/voc", line 296, in
run(main(args), debug=debug)
File "/usr/local/lib/python3.7/asyncio/runners.py", line 43, in run
return loop.run_until_complete(main)
File "/usr/local/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete
return future.result()
File "/home/pi/.local/bin/voc", line 246, in main
await vehicle.honk_and_blink()
TypeError: object NoneType can't be used in 'await' expression

Any idea?

CarEvent

Good evening everyone,

I'm having trouble understanding the other # carEvent function ...
When I test from Postman, I cannot access this resource.
I am developing a script for recording intermediate GPS coordinates in order to plot the routes on a Leaflet map.
At the beginning I based myself on EngineRunning but it is inoperative ...
The notion of trigger would be saving for me.

More generally, how does the recording of a trip work?

Thanks for your help.

Bruce

License statement

Currently there is no license statement. Could you please add a LICENSE file that contains the license text.

Thanks.

Recurring error in logs

Hi!

I am trying to get volvooncall working in my HA (0.51.1 on docker). If I enable debug, I see a successful login to the VOC servers, and successful retrieval of lots of car data .. however, nothing showing in HA. I see the following recurring error in logs and wonder if this is the issue:

2017-08-14 20:56:13 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/local/lib/python3.6/asyncio/tasks.py", line 180, in _step
result = coro.send(None)
File "/usr/src/app/homeassistant/helpers/entity.py", line 205, in async_update_ha_state
"No entity id specified for entity {}".format(self.name))
File "/usr/src/app/homeassistant/components/volvooncall.py", line 157, in name
self._vehicle_name,
File "/usr/src/app/homeassistant/components/volvooncall.py", line 146, in vehicle_name
self.vehicle.registration_number.lower()) or
AttributeError: 'NoneType' object has no attribute 'lower'
2017-08-14 20:56:13 ERROR (MainThread) [homeassistant.core] Error doing job: Future exception was never retrieved
Traceback (most recent call last):
File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 55, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/src/app/homeassistant/components/device_tracker/volvooncall.py", line 28, in see_vehicle
dev_id = 'volvo
{}'.format(slugify(host_name))
File "/usr/src/app/homeassistant/util/init.py", line 42, in slugify
text = normalize('NFKD', text)
TypeError: normalize() argument 2 must be str, not None

My config.yaml:
#Volvo
volvooncall:
username: myusername
password: !secret volvo_pwd
service_url: 'https://vocapi-na.wirelesscar.net/customerapi/rest/v3.0/'

Thanks!

How to install?

Sorry for the beginner's question. But I'm not experienced with python packages. How can I install this on my machines (OSX or Debian Linux) to use? I have some basic skills in Linux and C++/Java/JS but not Python. Please help me.

Monitoring Communication

Hello Erik,

I used to use the remote lock/unlock and the start/stop heater functionality for quite a long time, but recently I noticed that it didn't function any more.

A more detailed search with the original VoC app gave me the following information:

Lock
Your Volvo has not been in use for
a while and is offline to not drain
battery. The Volvo on Call service
is waiting for your Volvo to come
back online, which normally happens
within an hour.
Do you still want to continue?

Obviously the car was in standby.
Further information gave:
Your Volvo may have difficulty
communicating if it has no mobile
coverage or is in power save mode.

Indeed I had not used my car for 6 days and that it went into power save mode is fully
acceptable, but if you send a command with the VoC python script, you don't get information that the script is not giving the desired result.

The question.
Are you aware of any command that monitors the connection between the car and the VoC server?
A way to solve it could be to monitor this sensor:
"timeFullyAccessible": 7200,
"timeFullyAccessibleUntil": "2019-06-25T14:12:06+00:00",
"timePartiallyAccessible": 31680,
"timePartiallyAccessibleUntil": "2019-07-12T14:12:06+00:00",

It turns out that after 7200 minutes (= 5 days) the car goes in power save mode
Something else will happen after 22 days (31680) minutes, but I have no idea, what will happen on July 12, if I don"t use the car before that date.

Is it possible to implement a function that a warning is generated if the current date/time exceeds the date/time in timeFullyAccessible?

Or is there a better solution?

Regards,

Herman

Separate and cleanup requirements

While working on the Home-Assistant dependency bump, I've been wondering if it might be worth it to separate and cleanup the requirement a bit. This would definitely help reduce dependency conflicts but only installing what is truly needed.

At the moment all dependencies are specified in requirements.txt. This leads to a situation where amqtt needs to be installed for Home Assistant, and subsequently creates dependency conflicts, although it isn't even needed there. I would like to suggest splitting the dependencies into what is required for everything (these should remain as install_requires), and what is needed for the mqtt server. Those could be moved to extras_require.

The only downside would probably be that users would need to use pip install volvooncall[mqtt] instead if they want like to use the mqtt server.

Furthermore, I would recommend against reading the requirements from requirements.txt in setup.py. requirements.txt is still needed (for CI and testing) and thus should include all dependencies. Especially with the split, it would however be better to specify the dependencies independently in setup.cfg.

Last, I know I just recommended updating the websockets dependency. While checking the requirement, I just found that it isn't even used directly. So it might be safe to remove entirely? If other packages depend on it, they specify a dependency range for it themselves (eg. amqtt).

https://setuptools.pypa.io/en/latest/userguide/dependency_management.html#optional-dependencies

home-assistant/core#64942

/CC @decompil3d

Unable to stop display of trips in normal Print command

With the recent change, there's no information on how to prevent the display of the trips when running the "print" command. If modifying and changing volvooncall.py and setting the journal=True to journal=False (as per the latest commit), the journal display is gone from the "print" command, however, setting it False now causes the normal "trips" command to break.

Vehicle not found

I put the .conf file into my Home on Mac, but it seems that VOC cannot find the vehicle when I ran any of the voc commends.
xnip2019-02-02_23-59-56

Python 3 required

I am running this on a RPI3 and of some reason i now receive Python 3 required but i have not changed anything what i now.

I have python 3.5.3 installed

/Mike

Added functionality for Tailgate and Average Speed.

Hi,

While implementing MQTT function, I noted that both Average Speed and the Tailgate was missing in the sensor, resp binary sensor, section. So I made some add on coding in the dashboard py file.
It works for me, but I have no idea if there is a side effect in Home Assistant, such as the choice for the icon (mdi:ruler)
See below:

   Sensor(
        attr="fuelAmountLevel",
        name="Fuel level",
        icon="mdi:water-percent",
        unit="%",
    ),
    FuelConsumption(),
    Sensor(
        attr="distanceToEmpty", name="Range", icon="mdi:ruler", unit="km"
    ),
    Sensor(
        attr="averageSpeed",
        name="Average speed",
        icon="mdi:ruler",
        unit="km/h",
    ),
    Sensor(
        attr="hvBattery.distanceToHVBatteryEmpty",
        name="Battery range",
        icon="mdi:ruler",
        unit="km",
    ),

AND

    BinarySensor(
        attr="doors.rearRightDoorOpen",
        name="Rear right door",
        device_class="door",
    ),
    BinarySensor(
        attr="doors.tailgateOpen",
        name="Tailgate",
        device_class="door",
    ),
    BinarySensor(
        attr="windows.frontLeftWindowOpen",
        name="Front left window",
        device_class="window",

Please check.

voc dashboard

voc dashboard does not handle my Volvo V90 T8 supported features set properly.
When I run it with -vv debug option, last lines are:

18-11-30 08:32.13 DEBUG (MainThread) [dashboard] Setting up dashboard with config :{'username': 's[email protected]', 'password': '**', 'interval': '300', 'scandinavian_miles': False, 'immutable': False}
18-11-30 08:32.13 DEBUG (MainThread) [dashboard] ILL-329 Position is supported
18-11-30 08:32.13 DEBUG (MainThread) [dashboard] ILL-329 Door lock is supported
18-11-30 08:32.13 DEBUG (MainThread) [dashboard] ILL-329 Heater is supported
18-11-30 08:32.13 DEBUG (MainThread) [dashboard] ILL-329 Odometer is supported
18-11-30 08:32.13 DEBUG (MainThread) [dashboard] ILL-329 Trip meter 1 is supported
18-11-30 08:32.13 DEBUG (MainThread) [dashboard] ILL-329 Trip meter 2 is supported
18-11-30 08:32.13 DEBUG (MainThread) [dashboard] ILL-329 Fuel amount is supported
18-11-30 08:32.13 DEBUG (MainThread) [dashboard] ILL-329 Fuel level is supported
18-11-30 08:32.13 DEBUG (MainThread) [dashboard] ILL-329 Fuel consumption is supported
18-11-30 08:32.13 DEBUG (MainThread) [dashboard] ILL-329 Range is supported
18-11-30 08:32.13 DEBUG (MainThread) [dashboard] ILL-329 Battery range is supported
18-11-30 08:32.13 DEBUG (MainThread) [dashboard] ILL-329 Battery level is supported
18-11-30 08:32.13 DEBUG (MainThread) [dashboard] ILL-329 Time to fully charged is supported
18-11-30 08:32.13 DEBUG (MainThread) [dashboard] ILL-329 Battery charging is supported
18-11-30 08:32.13 DEBUG (MainThread) [dashboard] ILL-329 Engine is supported
18-11-30 08:32.13 DEBUG (MainThread) [dashboard] ILL-329 Last trip is supported
Traceback (most recent call last):
File "./voc", line 269, in
run(main(args), debug=debug)
File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/runners.py", line 43, in run
return loop.run_until_complete(main)
File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/base_events.py", line 568, in run_until_complete
return future.result()
File "./voc", line 219, in main
dashboard = vehicle.dashboard(**credentials)
File "/Users/skrainik/Private/volvooncall/volvooncall.py", line 415, in dashboard
return Dashboard(self, **config)
File "/Users/skrainik/Private/volvooncall/dashboard.py", line 477, in init
for instrument in create_instruments()
File "/Users/skrainik/Private/volvooncall/dashboard.py", line 478, in
if instrument.setup(vehicle, **config)
File "/Users/skrainik/Private/volvooncall/dashboard.py", line 38, in setup
if not self.is_supported:
File "/Users/skrainik/Private/volvooncall/dashboard.py", line 66, in is_supported
if hasattr(self.vehicle, self.attr):
File "/Users/skrainik/Private/volvooncall/volvooncall.py", line 251, in is_engine_running
'on' in engine_remote_start_status)
TypeError: argument of type 'NoneType' is not iterable

Syntax Error

First off, thanks for the work you have done. I do own a Volvo XC90 and I'd love to write a driver for it that works with NEEO.

I did clone, then build and install, but I am honestly no pro. I am assuming I am doing something wrong rather then you actually having published a syntax error.

Would be lovely if you could hint me in the right directon. This is the error I am getting:

pi@raspiTR2ImageFTP:~/volvooncall $ voc --version Traceback (most recent call last): File "/usr/local/bin/voc", line 4, in <module> __import__('pkg_resources').run_script('volvooncall==0.5.0', 'voc') File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 534, in run_script self.require(requires)[0].run_script(script_name, ns) File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1444, in run_script script_code = compile(script_text, script_filename,'exec') File "/usr/local/lib/python2.7/dist-packages/volvooncall-0.5.0-py2.7.egg/EGG-INFO/scripts/voc", line 208 print(f'{instrument}: {instrument.str_state}') ^ SyntaxError: invalid syntax

Heater error with Home Assistant

I get this error with the latest version installed:
17-03-12 19:42:51 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/usr/lib/python3.4/asyncio/tasks.py", line 237, in _step result = next(coro) File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/helpers/entity.py", line 215, in async_update_ha_state state = self.state File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/helpers/entity.py", line 326, in state return STATE_ON if self.is_on else STATE_OFF File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/switch/volvooncall.py", line 30, in is_on return self.vehicle.is_heater_on File "/home/homeassistant/.homeassistant/deps/volvooncall.py", line 185, in is_heater_on self.heater['status'] != 'off') KeyError: 'status'

I do have a heater in my Volvo, but reading current state is not supported.

Trips display affected in latest 0.6.4 codebase

Looks like the dashboard display is now affected by the change for the trips output.

COMPUTER:~$ voc dashboard
UNKNOWN Position: (XXX, XXX)
UNKNOWN Door lock: Locked
UNKNOWN Heater: Off
UNKNOWN Odometer: 1219 mil
UNKNOWN Trip meter 1: 76 mil
UNKNOWN Trip meter 2: 1 mil
UNKNOWN Fuel amount: 7 L
UNKNOWN Fuel level: 14 %
UNKNOWN Fuel consumption: 0.53 L/mil
UNKNOWN Range: 4.8 mil
UNKNOWN Battery range: 1.5 mil
UNKNOWN Battery level: 66 %
UNKNOWN Time to fully charged: 60 minutes
UNKNOWN Battery charging: Charging
UNKNOWN Engine: Off
Traceback (most recent call last):
File "/usr/local/bin/voc", line 235, in
main()
File "/usr/local/bin/voc", line 226, in main
print(f'{instrument}: {instrument.str_state}')
File "/usr/local/lib/python3.6/dist-packages/dashboard.py", line 83, in str_state
return f'{self.state} {self.unit}'

File "/usr/local/lib/python3.6/dist-packages/dashboard.py", line 178, in state
if self.trip:

File "/usr/local/lib/python3.6/dist-packages/dashboard.py", line 149, in trip
if self.vehicle.trips:

File "/usr/local/lib/python3.6/dist-packages/volvooncall.py", line 319, in trips
return self.attrs['trips']

KeyError: 'trips'
COMPUTER:~$

Send to car

Hey Molobrakos.
A send location to the car navigator would be a nice add-on to this.

I've integrated my Google Calendar to Homeassistant and already use it to calculate the travel time with Waze for the next scheduled meeting, and if Homeassistant also could send it to Volvo that would be great.

Another small issue is that I'm actually missing the trunk-sensor. Of course it can be solved by see if status is open on all doors, while left and right front and back doors are closed.

Honk and Blink

Hello Erik,

After I got a new car some weeks ago, I decided to look once again to this issue.
Although some developers claim that the function honk and blink is supported I only see posts that users can't get it to work. However most users do not pay much attention to this function, but it would be nice to make it work. Some other developments are all based on your script, as you might know. So I don't think their claims are correct.

I tested it with, what I believe, all possible combinations of honk_and_blink and/or call but it didn't function.

So I decided to use a capture app on the phone and to capture the data send from the VoC app to the server.
Regarding honk and blink see the results below:

X-Client-Version: 4.4.5.21126
X-Device-Id: 55792eff9c2ac026
X-OS-Type: Android
X-App-Name: Volvo On Call
X-OS-Version: 23
X-Originator-Type: app
Accept: application/vnd.wirelesscar.com.voc.Service.v4+json; charset=utf-8
X-Request-Id: 436c176a-f547-4206-af85-c63a4364b0d8
Locale: en_GB
Authorization: Basic XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Content-Type: application/vnd.wirelesscar.com.voc.ClientPosition.v4+json; charset=utf-8
User-Agent: Dalvik/2.1.0 (Linux; U; Android 6.0.1; MotoG3 Build/MPIS24.107-55-2-17)
Host: vocapi.wirelesscar.net
Connection: Keep-Alive
Accept-Encoding: gzip
Content-Length: 94

{"clientAccuracy":0.0,"clientLatitude":lat_coordinate,"clientLongitude":lon_coordinate}

//Received command from VoC server to VoC application

HTTP/1.1 200 OK
Server: nginx
Date: Thu, 01 Aug 2019 13:52:38 GMT
Content-Type: application/vnd.wirelesscar.com.voc.Service.v4+json;charset=utf-8
Content-Length: 317
Connection: keep-alive
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
Strict-Transport-Security: max-age=31536000 ; includeSubDomains
X-XSS-Protection: 1; mode=block
X-Frame-Options: DENY
X-Content-Type-Options: nosniff
Strict-Transport-Security: max-age=31536000

{"status":"Started","statusTimestamp":"2019-08-01T13:52:38+0000","startTime":"2019-08-01T13:52:38+0000","serviceType":"RHBLF","failureReason":null,"service":"https://vocapi.wirelesscar.net/customerapi/rest/vehicles//services/number_7_digits","vehicleId":"","customerServiceId":"number_7_digits"}

// Send command from VoC application to VoC server

GET /customerapi/rest/vehicles//services/number_7_digits
HTTP/1.1
X-Client-Version: 4.4.5.21126
X-Device-Id: 55792eff9c2ac026
X-OS-Type: Android
X-App-Name: Volvo On Call
X-OS-Version: 23
X-Originator-Type: app
Accept: application/vnd.wirelesscar.com.voc.Service.v4+json; charset=utf-8
X-Request-Id: 8afe1536-8ad3-4748-873f-752c1ca478a9
Locale: en_GB
Authorization: Basic XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
User-Agent: Dalvik/2.1.0 (Linux; U; Android 6.0.1; MotoG3 Build/MPIS24.107-55-2-17)
Host: vocapi.wirelesscar.net
Connection: Keep-Alive
Accept-Encoding: gzip

//Received command from VoC server to VoC application

HTTP/1.1 200 OK
Server: nginx
Date: Thu, 01 Aug 2019 13:52:44 GMT
Content-Type: application/vnd.wirelesscar.com.voc.Service.v4+json;charset=utf-8
Content-Length: 326
Connection: keep-alive
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
Strict-Transport-Security: max-age=31536000 ; includeSubDomains
X-XSS-Protection: 1; mode=block
X-Frame-Options: DENY
X-Content-Type-Options: nosniff
Strict-Transport-Security: max-age=31536000

{"status":"MessageDelivered","statusTimestamp":"2019-08-01T13:52:41+0000","startTime":"2019-08-01T13:52:38+0000","serviceType":"RHBLF","failureReason":null,"service":"https://vocapi.wirelesscar.net/customerapi/rest/vehicles//services/number_7_digits","vehicleId":"","customerServiceId":"number_7_digits"}

//Send command from VoC application to VoC server

GET /customerapi/rest/vehicles//services/number_7_digits HTTP/1.1
X-Client-Version: 4.4.5.21126
X-Device-Id: 55792eff9c2ac026
X-OS-Type: Android
X-App-Name: Volvo On Call
X-OS-Version: 23
X-Originator-Type: app
Accept: application/vnd.wirelesscar.com.voc.Service.v4+json; charset=utf-8
X-Request-Id: eaf23680-a38b-4fcb-a0fc-147cb2ae1bed
Locale: en_GB
Authorization: Basic XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
User-Agent: Dalvik/2.1.0 (Linux; U; Android 6.0.1; MotoG3 Build/MPIS24.107-55-2-17)
Host: vocapi.wirelesscar.net
Connection: Keep-Alive
Accept-Encoding: gzip

//Received command from VoC server to VoC application

HTTP/1.1 200 OK
Server: nginx
Date: Thu, 01 Aug 2019 13:52:54 GMT
Content-Type: application/vnd.wirelesscar.com.voc.Service.v4+json;charset=utf-8
Content-Length: 320
Connection: keep-alive
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
Strict-Transport-Security: max-age=31536000 ; includeSubDomains
X-XSS-Protection: 1; mode=block
X-Frame-Options: DENY
X-Content-Type-Options: nosniff
Strict-Transport-Security: max-age=31536000
{"status":"Successful","statusTimestamp":"2019-08-01T13:52:49+0000","startTime":"2019-08-01T13:52:38+0000","serviceType":"RHBLF","failureReason":null,"service":"https://vocapi.wirelesscar.net/customerapi/rest/vehicles//services/number_7_digits","vehicleId":"","customerServiceId":"number_7_digits"}

The lines after // are my comments.
For privacy reasons, I removed my VIN number and the lat and lon co-ordinates.
If you look to the message sequence, you see that they use a so called: "customerServiceId":"number_7_digits".
This is a seven digit number, that I have removed for privacy reasons as well.

The question is:
Is it possible to make honk and blink work?
Would be nice?

Regards,

Herman

Unlock

Hi!

While the lock command works perfeclty, I get a 500 at unlocking the car:

20-05-04 10:09.00 WARNING (MainThread) [volvooncall.volvooncall] Failure when communcating with the server: 500, message='Internal Server Error', url=URL('https://vocapi.wirelesscar.net/customerapi/rest/v3.0/vehicles/......./unlock')
20-05-04 10:09.00 WARNING (MainThread) [volvooncall.volvooncall] Failure to execute: 500, message='Internal Server Error', url=URL('https://vocapi.wirelesscar.net/customerapi/rest/v3.0/vehicles/...../unlock')

Error running MQTT in docker

Hi,
When I try to run ./voc mqtt in the docker container I get un error:

Traceback (most recent call last):
  File "./voc", line 235, in <module>
    main()
  File "./voc", line 231, in main
    run(connection, credentials)
  File "/app/mqtt.py", line 407, in run
    port=int(mqtt_config['port']))
  File "/usr/local/lib/python3.6/site-packages/paho/mqtt/client.py", line 839, in connect
    return self.reconnect()
  File "/usr/local/lib/python3.6/site-packages/paho/mqtt/client.py", line 994, in reconnect
    sock.do_handshake()
  File "/usr/local/lib/python3.6/ssl.py", line 1077, in do_handshake
    self._sslobj.do_handshake()
  File "/usr/local/lib/python3.6/ssl.py", line 689, in do_handshake
    self._sslobj.do_handshake()
OSError: [Errno 0] Error

This is how I run it:

docker build -t molobrakos/voc .
docker run --name=voc --restart=always --detach --net=bridge  -v <full path to voc.conf>:/app/.config/voc.conf:ro -v <full path to mosquitto_pub>:/app/.config/mosquitto_pub:ro molobrakos/voc -vv

When I the look at docker logs voc:

<First a dump from VoC, with all my cars data>
Traceback (most recent call last):
  File "./voc", line 235, in <module>
    main()
  File "./voc", line 231, in main
    run(connection, credentials)
  File "/app/mqtt.py", line 407, in run
    port=int(mqtt_config['port']))
  File "/usr/local/lib/python3.6/site-packages/paho/mqtt/client.py", line 839, in connect
    return self.reconnect()
  File "/usr/local/lib/python3.6/site-packages/paho/mqtt/client.py", line 994, in reconnect
    sock.do_handshake()
  File "/usr/local/lib/python3.6/ssl.py", line 1077, in do_handshake
    self._sslobj.do_handshake()
  File "/usr/local/lib/python3.6/ssl.py", line 689, in do_handshake
    self._sslobj.do_handshake()
OSError: [Errno 0] Error

401 Unauthorized

Hi,

I got an issue when trying to get status of my car.

At begining, i think it was a password issue but even if i change it, i got same issue.

I am on Europe servers, i try with -r eu but same issue.

ogiffard@LAPTOP741618:~/GIT/volvooncall$ voc -u "@gl.com" -p "*" status
Traceback (most recent call last):
File "/usr/local/bin/voc", line 4, in
import('pkg_resources').run_script('volvooncall==0.8.12', 'voc')
File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 658, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 1438, in run_script
exec(code, namespace, namespace)
File "/usr/local/lib/python3.6/dist-packages/volvooncall-0.8.12-py3.6.egg/EGG-INFO/scripts/voc", line 291, in
run(main(args), debug=debug)
File "/usr/local/lib/python3.6/dist-packages/volvooncall-0.8.12-py3.6.egg/EGG-INFO/scripts/voc", line 283, in run
loop.run_until_complete(fut)
File "/usr/lib/python3.6/asyncio/base_events.py", line 484, in run_until_complete
return future.result()
File "/usr/local/lib/python3.6/dist-packages/volvooncall-0.8.12-py3.6.egg/EGG-INFO/scripts/voc", line 152, in main
res = await connection.update(journal=journal)
File "/usr/local/lib/python3.6/dist-packages/volvooncall-0.8.12-py3.6.egg/volvooncall/volvooncall.py", line 105, in update
user = await self.get("customeraccounts")
File "/usr/local/lib/python3.6/dist-packages/volvooncall-0.8.12-py3.6.egg/volvooncall/volvooncall.py", line 91, in get
return await self._request(METH_GET, self._make_url(url, rel))
File "/usr/local/lib/python3.6/dist-packages/volvooncall-0.8.12-py3.6.egg/volvooncall/volvooncall.py", line 76, in _request
response.raise_for_status()
File "/usr/local/lib/python3.6/dist-packages/aiohttp-4.0.0a0-py3.6-linux-x86_64.egg/aiohttp/client_reqrep.py", line 942, in raise_for_status
headers=self.headers)
aiohttp.client_exceptions.ClientResponseError: 401, message='Unauthorized'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.