molobrakos / volvooncall

Retrieve information from the Volvo On Call (VOC) web service
The Unlicense
158 stars 51 forks source link

Engine support in Home Assistant #23

Closed tenfire closed 5 years ago

tenfire commented 6 years ago

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.

molobrakos commented 6 years ago

Yep, that's the plan! I have been waiting for the API to stabilize. Also, I want to get rid of as much voc-specific stuff as possible in HA, such as enumerating all available resources and instead letting the voc lib provide all available instruments. Glad to hear the engine start functionality is working for you, it is not supported by my car so I haven't been able to test it myself at all.

molobrakos commented 6 years ago

Maybe you can test https://github.com/molobrakos/home-assistant/tree/new-voc and report if it works ok for you? (My car does not support starting/stopping engine from the api) Diff here: https://github.com/home-assistant/home-assistant/compare/dev...molobrakos:new-voc

tenfire commented 6 years ago

Hi, I could not get it to work. The heater did not work either. Log:

2018-09-05 17:22:19 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=switch, service=turn_on, service_data=entity_id=switch.megatron_engine> 2018-09-05 17:22:19 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_executed[L]>

2018-09-05 17:22:44 INFO (SyncWorker_11) [volvooncall] Updating

2018-09-05 17:22:46 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/home/erik/homeassistant/home-assistant/homeassistant/helpers/entity.py", line 250, in async_update_ha_state device_class = self.device_class File "/home/erik/homeassistant/home-assistant/homeassistant/components/binary_sensor/volvooncall.py", line 33, in device_class return self.instrument.device_class AttributeError: 'EngineStart' object has no attribute 'device_class' 2018-09-05 17:22:46 ERROR (MainThread) [dashboard] Can not encode state None:<class 'NoneType'> 2018-09-05 17:22:46 ERROR (MainThread) [dashboard] Can not encode state None:<class 'NoneType'> 2018-09-05 17:22:46 ERROR (MainThread) [dashboard] Can not encode state None:<class 'NoneType'> 2018-09-05 17:22:46 ERROR (MainThread) [dashboard] Can not encode state None:<class 'NoneType'>

molobrakos commented 6 years ago

Oh, ok, that should be fixed now. Can you please test again?

tenfire commented 6 years ago

Heater and Engine started and stopped using the switches. Although the state for the engine was shown as off all the time, even though it actually was on. The heater updated the state as it should.

molobrakos commented 6 years ago

Although the state for the engine was shown as off all the time, even though it actually was on.

By this you mean the engine status binary sensor or the engine switch? (both are available, since not all vehicles supports starting the engine, only viewing the current state)

tenfire commented 6 years ago

I mean the engine switch in homeassistant.

molobrakos commented 6 years ago

Added a forced update from the server after calling start/stop engine as well as lock/unlock. Maybe it works better now?

tenfire commented 6 years ago

The engine still starts fine but both the binary sensor and the switch still has the state "off" after I turned it on using the switch. I even tried restarting home assistant while the engine was running, still "off".

I tried playing around with voc and found that 'engineRunning' never changed to true, even though the Android Volvo On Call app reports that it is on.

The only difference I could find in the status output was this.

Engine on:

'ERS': {
'status': 'onByDirectCtrl',
'timestamp': datetime.datetime(2018, 9, 15, 15, 59, 6, tzinfo=datetime.timezone.utc), 
'engineStartWarning':'None',
'engineStartWarningTimestamp': datetime.datetime(2018, 9, 15, 15, 59, 6, tzinfo=datetime.timezone.utc)
}

Engine off (MaxAttemptsExceeded since I can only remote start 2 times before starting normally):

'ERS': {
'status':'off',
'timestamp': datetime.datetime(2018, 9, 15, 16, 17, 37, tzinfo=datetime.timezone.utc),
'engineStartWarning': 'MaxAttemptsExceeded',
'engineStartWarningTimestamp': datetime.datetime(2018, 9, 15, 16, 17, 37, tzinfo=datetime.timezone.utc)
}

So, ERS (engine remote start?) is probably being used instead of engineRunning.

molobrakos commented 6 years ago

Please test https://github.com/molobrakos/volvooncall/commit/18bfcfcb6e9ebfb0790dbe240da1fabfd718ba07

tenfire commented 6 years ago

Will test it now

tenfire commented 6 years ago

Seems like the dashboard does not display the correct value for the engine. Both dashboard and status printed "off" when the engine was off as it should.

Output (status/dashboard) with the engine running (remote started):

erik@Server-Erik:~/volvooncall$ ./voc status
<REMOVED> (XC60/2019) <REMOVED> 10224km (fuel 47% 390km)
    position: <REMOVED>, <REMOVED>
    engine: on
    locked: yes
    heater: off
erik@Server-Erik:~/volvooncall$ ./voc -i <REMOVED> dashboard
<REMOVED> Position: (<REMOVED>, <REMOVED>)
<REMOVED> Door lock: Locked
<REMOVED> Heater: Off
<REMOVED> Odometer: 10225 km
<REMOVED> Trip meter 1: 225 km
<REMOVED> Trip meter 2: 4 km
<REMOVED> Fuel amount: 34 L
<REMOVED> Fuel level: 47 %
<REMOVED> Fuel consumption: 8.0 L/100 km
<REMOVED> Range: 390 km
<REMOVED> Engine: Off
<REMOVED> Last trip: 2018-09-26 17:11:21+02:00
<REMOVED> Engine: Off
<REMOVED> Hood: Closed
<REMOVED> Front left door: Closed
<REMOVED> Front right door: Closed
<REMOVED> Rear left door: Closed
<REMOVED> Rear right door: Closed
<REMOVED> Front left window: Closed
<REMOVED> Front right window: Closed
<REMOVED> Rear left window: Closed
<REMOVED> Rear right window: Closed
18-09-26 18:11.57 ERROR (MainThread) [dashboard] Can not encode state None:<class 'NoneType'>
<REMOVED> Front right tyre: OK
18-09-26 18:11.57 ERROR (MainThread) [dashboard] Can not encode state None:<class 'NoneType'>
<REMOVED> Front left tyre: OK
18-09-26 18:11.57 ERROR (MainThread) [dashboard] Can not encode state None:<class 'NoneType'>
<REMOVED> Rear right tyre: OK
18-09-26 18:11.57 ERROR (MainThread) [dashboard] Can not encode state None:<class 'NoneType'>
<REMOVED> Rear left tyre: OK
<REMOVED> Washer fluid: OK
<REMOVED> Brake Fluid: OK
<REMOVED> Service: OK
<REMOVED> Bulbs: OK
<REMOVED> Doors: Closed
<REMOVED> Windows: Closed
molobrakos commented 6 years ago

heh, I guess we need a proper test suite with mocked server responses and expected results...

molobrakos commented 6 years ago

Like this: https://github.com/molobrakos/volvooncall/blob/master/test_main.py#L101 (test passes)

molobrakos commented 6 years ago

Let me know when you have tested this and I'll release a new version that can be used with Home Assistant.

fluppie commented 6 years ago

I just got my new 2019 V60 today, the Volvo on call plugin is working. Also want remote start in home assistant😊😊. This feature is supported by mine, so I can test this if needed.

molobrakos commented 6 years ago

Please do

fluppie commented 6 years ago

I replaced the volvooncall.py file from your Github but this give me some errors:

Log Details (ERROR)

Fri Oct 26 2018 23:40:30 GMT+0200 (Romance (zomertijd))

Error loading homeassistant.components.volvooncall. Make sure all dependencies are installed

Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/loader.py", line 92, in get_component
    module = importlib.import_module(path)
  File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 673, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/volvooncall.py", line 18, in <module>
    from util import obj_parser, json_serialize, is_valid_path, find_path
ImportError: No module named 'util'
tenfire commented 6 years ago

I can test later today. What test should I do? Just voc dashboard and voc status, or can I test it in your home-assistant fork as well?

molobrakos commented 6 years ago

Great, thanks! Primarily the stuff you reported here: https://github.com/molobrakos/volvooncall/issues/23#issuecomment-424779217 You can also test my Home Assistant branch here: https://github.com/molobrakos/home-assistant/tree/new-voc which contains the updated voc-stuff.

fluppie commented 6 years ago

Can I just replace the files in my HA installation 0.80.3 where I see modifications?

Like listed here: https://github.com/home-assistant/home-assistant/compare/dev...molobrakos:new-voc

tenfire commented 6 years ago

Test results: voc status: Engine status is reported correctly

voc dashboard: Engine status is reported correctly

homeassistant switch-on: Engine is turned on, engine switch state is updated to "On". Minor delay (10-15 sec) homeassistant switch-off: Engine is turned off, engine switch state is updated to "Off" after some delay (1-2 minutes)

tenfire commented 6 years ago

@fluppie I followed these instructions to get started:

https://developers.home-assistant.io/docs/en/development_environment.html

fluppie commented 6 years ago

OK, I made a dev environment and cloned from molobrakos github, it gives me a 0.77.0.dev0 Home Assistant env. Hereby the log:

(home-assistant) pi@hassbian:~/home-assistant $ hass Config directory: /home/pi/.homeassistant

2018-10-29 17:49:44 INFO (MainThread) [homeassistant.loader] Loaded script from homeassistant.components.script 2018-10-29 17:49:44 INFO (MainThread) [homeassistant.loader] Loaded conversation from homeassistant.components.conversation 2018-10-29 17:49:44 INFO (MainThread) [homeassistant.loader] Loaded volvooncall from homeassistant.components.volvooncall 2018-10-29 17:49:44 INFO (MainThread) [homeassistant.loader] Loaded tts from homeassistant.components.tts 2018-10-29 17:49:44 INFO (MainThread) [homeassistant.loader] Loaded tts.google from homeassistant.components.tts.google 2018-10-29 17:49:44 INFO (MainThread) [homeassistant.loader] Loaded cloud from homeassistant.components.cloud 2018-10-29 17:49:44 INFO (MainThread) [homeassistant.loader] Loaded updater from homeassistant.components.updater 2018-10-29 17:49:44 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: old_state=None, entity_id=sun.sun, new_state=<state sun.sun=above_horizon; next_dawn=2018-10-30T05:18:56+00:00, next_noon=2018-10-30T11:43:38+00:00, next_dusk=2018-10-29T18:08:22+00:00, next_rising=2018-10-30T05:40:13+00:00, next_midnight=2018-10-29T23:43:38+00:00, elevation=13.14, next_setting=2018-10-29T17:47:08+00:00, azimuth=255.8, friendly_name=Sun @ 2018-10-29T16:49:44.734889+00:00>> 2018-10-29 17:49:44 INFO (MainThread) [homeassistant.setup] Setting up discovery 2018-10-29 17:49:44 ERROR (MainThread) [homeassistant.setup] Error during setup of component discovery Traceback (most recent call last): File "/home/pi/home-assistant/homeassistant/setup.py", line 145, in _async_setup_component hass, processed_config) File "/home/pi/home-assistant/homeassistant/components/discovery.py", line 111, in async_setup from netdisco.discovery import NetworkDiscovery File "/home/pi/home-assistant/lib/python3.5/site-packages/netdisco/discovery.py", line 6, in from .ssdp import SSDP File "/home/pi/home-assistant/lib/python3.5/site-packages/netdisco/ssdp.py", line 11, in from netdisco.util import etree_to_dict, interface_addresses File "/home/pi/home-assistant/lib/python3.5/site-packages/netdisco/util.py", line 4, in import netifaces ImportError: No module named 'netifaces' 2018-10-29 17:49:44 INFO (MainThread) [homeassistant.setup] Setting up automation

2018-10-29 17:49:44 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_executed[L]> 2018-10-29 17:49:44 INFO (MainThread) [homeassistant.core] Bus:Handling <Event component_loaded[L]: component=config.entity_registry> 2018-10-29 17:49:44 INFO (MainThread) [homeassistant.setup] Setting up volvooncall 2018-10-29 17:49:44 INFO (Thread-8) [volvooncall] Initializing volvooncall version: 0.6.11 2018-10-29 17:49:44 INFO (Thread-8) [homeassistant.components.volvooncall] Logging in to service 2018-10-29 17:49:44 INFO (Thread-8) [volvooncall] Updating 2018-10-29 17:49:44 INFO (Thread-8) [volvooncall] Querying vehicles 2018-10-29 17:49:45 INFO (MainThread) [homeassistant.setup] Setting up updater 2018-10-29 17:49:45 WARNING (MainThread) [homeassistant.components.updater] Running on 'dev', only analytics will be submitted

2018-10-29 17:49:46 ERROR (MainThread) [homeassistant.setup] Error during setup of component volvooncall Traceback (most recent call last): File "/home/pi/home-assistant/homeassistant/setup.py", line 148, in _async_setup_component component.setup, hass, processed_config) # type: ignore File "/usr/lib/python3.5/asyncio/futures.py", line 380, in iter yield self # This tells Task to wait for completion. File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup future.result() File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result raise self._exception File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run result = self.fn(*self.args, **self.kwargs) File "/home/pi/home-assistant/homeassistant/components/volvooncall.py", line 104, in setup return update(utcnow()) File "/home/pi/home-assistant/homeassistant/components/volvooncall.py", line 91, in update discover_vehicle(vehicle) File "/home/pi/home-assistant/homeassistant/components/volvooncall.py", line 73, in discover_vehicle dashboard = vehicle.dashboard File "/home/pi/home-assistant/lib/python3.5/site-packages/volvooncall.py", line 394, in dashboard from dashboard import Dashboard File "/home/pi/home-assistant/lib/python3.5/site-packages/dashboard.py", line 45 return f'{self.vehicle_name} {self.name}' ^ SyntaxError: invalid syntax 2018-10-29 17:49:46 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: service=create, service_data=message=The following components and platforms could not be set up:

fluppie commented 6 years ago

I tried again on a RPi system without HA:

2018-10-30 13:26:08 INFO (MainThread) [homeassistant.setup] Setup of domain sensor took 1.7 seconds. 2018-10-30 13:26:08 INFO (MainThread) [homeassistant.core] Bus:Handling <Event component_loaded[L]: component=sensor> 2018-10-30 13:26:08 ERROR (MainThread) [homeassistant.setup] Error during setup of component volvooncall Traceback (most recent call last): File "/home/pi/home-assistant/homeassistant/setup.py", line 148, in _async_setup_component component.setup, hass, processed_config) # type: ignore File "/usr/lib/python3.5/asyncio/futures.py", line 380, in iter yield self # This tells Task to wait for completion. File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup future.result() File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result raise self._exception File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run result = self.fn(*self.args, **self.kwargs) File "/home/pi/home-assistant/homeassistant/components/volvooncall.py", line 104, in setup return update(utcnow()) File "/home/pi/home-assistant/homeassistant/components/volvooncall.py", line 91, in update discover_vehicle(vehicle) File "/home/pi/home-assistant/homeassistant/components/volvooncall.py", line 73, in discover_vehicle dashboard = vehicle.dashboard File "/home/pi/home-assistant/lib/python3.5/site-packages/volvooncall.py", line 394, in dashboard from dashboard import Dashboard File "/home/pi/home-assistant/lib/python3.5/site-packages/dashboard.py", line 45 return f'{self.vehicle_name} {self.name}' ^ SyntaxError: invalid syntax 2018-10-30 13:26:08 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=persistent_notification, service_data=title=Invalid config, notification_id=invalid_config, message=The following components and platforms could not be set up:

When using git checkout master everyting works. So only the failure when using git checkout new-voc

fluppie commented 6 years ago

I just read this in the Readme:

system requirements At least python 3.6 or higher

Raspbian Stretch has 3.5.3 installed. So that could be my problem?

molobrakos commented 6 years ago

@fluppie, yes your Python version is too old.

fluppie commented 6 years ago

Working :) :)!!

afbeelding

molobrakos commented 6 years ago

voc status: Engine status is reported correctly voc dashboard: Engine status is reported correctly

Great!

homeassistant switch-on: Engine is turned on, engine switch state is updated to "On". Minor delay (10-15 sec) homeassistant switch-off: Engine is turned off, engine switch state is updated to "Off" after some delay (1-2 minutes)

Ok, I am not sure about the delay, but I think I will leave this for now. Maybe we can either set engine to on/off optimistically after executing each command. Or maybe we need to trigger an extra update from the server. Or maybe we have to wait for the server to update it's state form the vehicle first.

fluppie commented 6 years ago

Start/stop the engine is within 10s, most of the time 8.5s Engine status update 1 - 1.5 minutes Mine shows the heater, but I don't have that option on mine, it's also listed in the VOC app but gives an error after using it.

Can we also specify the timer for remote start? I think through the Volvo app we can select 1 to 15 min.

(home-assistant) pi@raspimqtt:~/home-assistant $ voc status -u xxxxx -p xxxxx
None (V60/2019) YV1ZWA00000000000 538km (fuel 20% 110km)
    position: 51.16406250000000,4.42350006103516
    engine: off
    locked: yes
    heater: off
(home-assistant) pi@raspimqtt:~/home-assistant $ voc dashboard -u xxxxx -p xxxxx
YV1ZWA00000000000 Position: (51.1640625, 4.423500061035156)
YV1ZWA00000000000 Door lock: Locked
YV1ZWA00000000000 Heater: Off
YV1ZWA00000000000 Odometer: 538 km
YV1ZWA00000000000 Trip meter 1: 538 km
YV1ZWA00000000000 Trip meter 2: 26 km
YV1ZWA00000000000 Fuel amount: 11 L
YV1ZWA00000000000 Fuel level: 20 %
YV1ZWA00000000000 Fuel consumption: 9.8 L/100 km
YV1ZWA00000000000 Range: 110 km
YV1ZWA00000000000 Engine: Off
YV1ZWA00000000000 Engine: Off
YV1ZWA00000000000 Hood: Closed
YV1ZWA00000000000 Front left door: Closed
YV1ZWA00000000000 Front right door: Closed
YV1ZWA00000000000 Rear left door: Closed
YV1ZWA00000000000 Rear right door: Closed
YV1ZWA00000000000 Front left window: Closed
YV1ZWA00000000000 Front right window: Closed
YV1ZWA00000000000 Rear left window: Closed
YV1ZWA00000000000 Rear right window: Closed
YV1ZWA00000000000 Front right tyre: OK
YV1ZWA00000000000 Front left tyre: OK
YV1ZWA00000000000 Rear right tyre: OK
YV1ZWA00000000000 Rear left tyre: OK
YV1ZWA00000000000 Washer fluid: OK
YV1ZWA00000000000 Brake Fluid: OK
YV1ZWA00000000000 Service: OK
YV1ZWA00000000000 Bulbs: OK
YV1ZWA00000000000 Doors: Closed
YV1ZWA00000000000 Windows: Closed
molobrakos commented 6 years ago

@fluppie if you do voc printand search for preclimatizationSupported, remoteClimatizationStatus, remoteHeaterSupported, and heater - what does it say for each item?

fluppie commented 6 years ago
"preclimatizationSupported": true,
"registrationNumber": null,
"remoteClimatizationStatus": null,
"remoteClimatizationStatusTimestamp": null,
"remoteHeaterSupported": false,
"sendPOIToVehicleVersionsSupported": [
    "sendSinglePOIToVehicle"
],
"serverVersion": "4.19.73-feature-CR_Fleet-voc-deployable",
"serviceWarningStatus": "Normal",
"serviceWarningStatusTimestamp": "2018-10-31T12:59:53+00:00",
"status.parkedIndoor.supported": false,
"subscriptionEndDate": "2021-10-26T00:00:00+00:00",
"subscriptionStartDate": "2018-10-26T00:00:00+00:00",
"subscriptionType": "PREMIUM_2013",
"theftAlarm": null,
"timeFullyAccessible": 7200,
"timeFullyAccessibleUntil": "2018-11-05T12:51:45+00:00",
"timePartiallyAccessible": 31680,
"timePartiallyAccessibleUntil": "2018-11-22T12:51:45+00:00",
"tripMeter1": 538300,
"tripMeter1Timestamp": "2018-10-31T12:59:53+00:00",
"tripMeter2": 26100,
"tripMeter2Timestamp": "2018-10-31T12:59:53+00:00",
"tyreDimensionCode": "2441R517",
"tyreInflationPressureHeavyCode": null,
"tyreInflationPressureLightCode": null,
"tyrePressure": {
    "frontLeftTyrePressure": null,
    "frontRightTyrePressure": null,
    "rearLeftTyrePressure": null,
    "rearRightTyrePressure": null,
    "timestamp": null
fluppie commented 6 years ago
    def start_engine(self):
        if self.is_engine_start_supported:
            self.call('engine/start', runtime=5)
self.update()

Can we make the runtime dynamic through a slider in Home Assistant? Or just default to 15min? I would think most people like to run it for 15min during wintertime?

I think the brightness slider from lights would be a good approach? afbeelding

fluppie commented 6 years ago

Can we add support for Blink and Honk&Blink?

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

{ "ERS": { "status": "off", "timestamp": "2018-10-31T14:45:05+00:00", "engineStartWarning": "MaxAttemptsExceeded", "engineStartWarningTimestamp": "2018-10-31T14:45:05+00:00" }, "VIN": "YV1ZWA00000000000", "assistanceCallSupported": true, "averageFuelConsumption": 98.0, "averageFuelConsumptionTimestamp": "2018-11-01T01:17:24+00:00", "averageSpeed": 49, "averageSpeedTimestamp": "2018-11-01T01:17:24+00:00", "bCallAssistanceNumber": "+3227736249", "brakeFluid": "Normal", "brakeFluidTimestamp": "2018-11-01T01:17:24+00:00", "bulbFailures": [], "bulbFailuresTimestamp": "2018-11-01T01:17:24+00:00", "calculatedPosition": { "longitude": null, "latitude": null, "timestamp": null, "speed": null, "heading": null }, "carLocatorDistance": 1000, "carLocatorSupported": true, "carLocked": true, "carLockedTimestamp": "2018-11-01T01:17:24+00:00", "climatizationCalendarMaxTimers": 8, "climatizationCalendarVersionsSupported": [ "climatizationCalendarV1" ], "country": { "iso2": "BE" }, "distanceToEmpty": 70, "distanceToEmptyTimestamp": "2018-11-01T01:17:24+00:00", "doors": { "tailgateOpen": false, "rearRightDoorOpen": false, "rearLeftDoorOpen": false, "frontRightDoorOpen": false, "frontLeftDoorOpen": false, "hoodOpen": false, "timestamp": "2018-11-01T01:17:24+00:00" }, "engineCode": "2441CF03", "engineRunning": false, "engineRunningTimestamp": "2018-11-01T01:17:24+00:00", "engineStartSupported": true, "exteriorCode": "2441110P", "fuelAmount": 7, "fuelAmountLevel": 12, "fuelAmountLevelTimestamp": "2018-11-01T01:17:24+00:00", "fuelAmountTimestamp": "2018-11-01T01:17:24+00:00", "fuelTankVolume": 55, "fuelType": "Diesel", "gearboxCode": "2441DB01", "grossWeight": 2260, "highVoltageBatterySupported": false, "honkAndBlinkDistance": 500, "honkAndBlinkSupported": true, "honkAndBlinkVersionsSupported": [ "honkAndOrBlink", "honkAndBlink" ], "interiorCode": "24411006", "journalLogEnabled": false, "journalLogSupported": true, "lockSupported": true, "maxActiveDelayChargingLocations": null, "modelYear": 2019, "numberOfDoors": 5, "odometer": 583693, "odometerTimestamp": "2018-11-01T01:17:24+00:00", "overrideDelayChargingSupported": false, "position": { "longitude": 4.0000082080078125, "latitude": 51.00000012939453, "timestamp": "2018-10-31T20:14:20+00:00", "speed": 0, "heading": 348 }, "preclimatizationSupported": true, "registrationNumber": null, "remoteClimatizationStatus": null, "remoteClimatizationStatusTimestamp": null, "remoteHeaterSupported": false, "sendPOIToVehicleVersionsSupported": [ "sendSinglePOIToVehicle" ], "serverVersion": "4.19.73-feature-CR_Fleet-voc-deployable", "serviceWarningStatus": "Normal", "serviceWarningStatusTimestamp": "2018-11-01T01:17:24+00:00", "status.parkedIndoor.supported": false, "subscriptionEndDate": "2021-10-26T00:00:00+00:00", "subscriptionStartDate": "2018-10-26T00:00:00+00:00", "subscriptionType": "PREMIUM_2013", "theftAlarm": null, "timeFullyAccessible": 7200, "timeFullyAccessibleUntil": "2018-11-05T20:13:45+00:00", "timePartiallyAccessible": 31680, "timePartiallyAccessibleUntil": "2018-11-22T20:13:45+00:00", "tripMeter1": 583600, "tripMeter1Timestamp": "2018-11-01T01:17:24+00:00", "tripMeter2": 71500, "tripMeter2Timestamp": "2018-11-01T01:17:24+00:00", "tyreDimensionCode": "2441R517", "tyreInflationPressureHeavyCode": null, "tyreInflationPressureLightCode": null, "tyrePressure": { "frontLeftTyrePressure": null, "frontRightTyrePressure": null, "rearLeftTyrePressure": null, "rearRightTyrePressure": null, "timestamp": null }, "unlockSupported": true, "unlockTimeFrame": 120, "vehiclePlatform": "2441", "vehicleType": "V60", "vehicleTypeCode": "2441AA0B", "verificationTimeFrame": 120, "vin": "YV1ZWA00000000000", "washerFluidLevel": "Normal", "washerFluidLevelTimestamp": "2018-11-01T01:17:24+00:00", "windows": { "frontLeftWindowOpen": false, "frontRightWindowOpen": false, "timestamp": "2018-11-01T01:17:24+00:00", "rearLeftWindowOpen": false, "rearRightWindowOpen": false } }

molobrakos commented 6 years ago

Can we add support for Blink and Honk&Blink?

Sure we can, feel free to submit a PR for this. Previous discussion in https://github.com/molobrakos/volvooncall/issues/19 (please continue discussion regarding this feature there).

molobrakos commented 6 years ago

Can we make the runtime dynamic through a slider in Home Assistant? Or just default to 15min? I would think most people like to run it for 15min during wintertime?

I think the brightness slider from lights would be a good approach?

Feel free to submit a PR for this (maybe a custom Home Assistant user interface-item has to be made as well. Or this might help you if you want to build something yourself using only the Home Assistant configuration: https://www.home-assistant.io/components/input_number/).

molobrakos commented 6 years ago

Mine shows the heater, but I don't have that option on mine, it's also listed in the VOC app but gives an error after using it.

My car only have support for the heater so I can not debug this. For previous discussion regarding heater vs preclimatization, please see: https://github.com/molobrakos/volvooncall/pull/2 (and please continue any discussion regarding this feature there). I am not sure what to do with this. Maybe we should separate preclimatization from heater entirely and provide two different switches, but in your case it would not work anyway, since your car does report preclimatizationSupported: true. Cc @nikagl

fluppie commented 6 years ago

Ok weird, was making a new setup to modify code and try new stuff. The steps I've done to make a working environment don't work anymore. Did meanwhile something change?

2018-11-01 11:16:56 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_executed[L]> 2018-11-01 11:16:56 INFO (SyncWorker_6) [homeassistant.util.package] Attempting install of volvooncall==0.6.12 2018-11-01 11:17:00 ERROR (SyncWorker_6) [homeassistant.util.package] Unable to install package volvooncall==0.6.12: Could not find a version that satisfies the requirement volvooncall==0.6.12 (from versions: 0.1.1, 0.1.2, 0.1.5, 0.1.6, 0.1.7, 0.1.8, 0.1.9, 0.1.10, 0.2.0, 0.3.0, 0.3.1, 0.3.2, 0.3.3, 0.4.0, 0.4.1, 0.4.2, 0.4.4, 0.5.0, 0.6.0, 0.6.1, 0.6.2, 0.6.3, 0.6.4, 0.6.5, 0.6.6, 0.6.7, 0.6.8, 0.6.9, 0.6.11) No matching distribution found for volvooncall==0.6.12 2018-11-01 11:17:00 ERROR (MainThread) [homeassistant.requirements] Not initializing volvooncall because could not install requirement volvooncall==0.6.12 2018-11-01 11:17:00 ERROR (MainThread) [homeassistant.setup] Setup failed for volvooncall: Could not install all requirements.

molobrakos commented 6 years ago

@fluppie sorry, something seems to have failed with 0.6.12. Please pull and test again.

fluppie commented 6 years ago

remote: Enumerating objects: 6, done. remote: Counting objects: 100% (6/6), done. remote: Compressing objects: 100% (2/2), done. remote: Total 6 (delta 4), reused 6 (delta 4), pack-reused 0 Unpacking objects: 100% (6/6), done. From https://github.com/molobrakos/home-assistant

  • dd84eceea...7bb79abc3 new-voc -> origin/new-voc (forced update) Auto-merging requirements_all.txt CONFLICT (content): Merge conflict in requirements_all.txt Auto-merging homeassistant/components/volvooncall.py CONFLICT (content): Merge conflict in homeassistant/components/volvooncall.py Automatic merge failed; fix conflicts and then commit the result.

Launching hass

2018-11-01 11:41:42 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/home/pi/home-assistant/homeassistant/setup.py", line 56, in async_setup_component return await task # type: ignore File "/home/pi/home-assistant/homeassistant/setup.py", line 103, in _async_setup_component component = loader.get_component(hass, domain) File "/home/pi/home-assistant/homeassistant/loader.py", line 94, in get_component module = importlib.import_module(path) File "/usr/local/lib/python3.6/importlib/init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 994, in _gcd_import File "", line 971, in _find_and_load File "", line 955, in _find_and_load_unlocked File "", line 665, in _load_unlocked File "", line 674, in exec_module File "", line 781, in get_code File "", line 741, in source_to_code File "", line 219, in _call_with_frames_removed File "/home/pi/home-assistant/homeassistant/components/volvooncall.py", line 25 <<<<<<< HEAD ^ SyntaxError: invalid syntax

Then I did git reset --hard origin/new-voc And all was fine

molobrakos commented 5 years ago

Hopefully works in Home Assistant dev-branch now, testing welcome!

tenfire commented 5 years ago

Hi, I have tested the homeassistant dev branch now.

I'll start with the state of the switch. While parked (remote start off): switch-state = off While parked (remote start on): switch-state = on While driving: switch-state = on

So far so good, however when I try to start/stop remotestart via the switch nothing happens, I did not see anything in my logs either. :(

tenfire commented 5 years ago

Can we also specify the timer for remote start? I think through the Volvo app we can select 1 to 15 min.

I agree with @fluppie that 15 minutes is probably more desirable as a default value since 5 minutes is not enough to defrost windows. I have created a pull request for this #37

molobrakos commented 5 years ago

So far so good, however when I try to start/stop remotestart via the switch nothing happens, I did not see anything in my logs either. :(

Does the standalone voc -vv engine start work?

tenfire commented 5 years ago

So far so good, however when I try to start/stop remotestart via the switch nothing happens, I did not see anything in my logs either. :(

Does the standalone voc -vv engine start work?

No, I got this: ./voc:229: RuntimeWarning: coroutine 'Vehicle.start_engine' was never awaited

tenfire commented 5 years ago

Tested the heater as well now, got the same result as for the engine

molobrakos commented 5 years ago

Ah, this commit fixes it: https://github.com/molobrakos/volvooncall/commit/9aeda75fc2c0895c6a7860677d075f46bc156f3e

tenfire commented 5 years ago

Got this now: 18-12-03 17:12.34 WARNING (MainThread) [volvooncall] Failure to execute: _request() missing 1 required positional argument: 'ref'

molobrakos commented 5 years ago

Thank you so much for your patience! How about this: https://github.com/molobrakos/volvooncall/commit/2663881e89b7826a6757df5090184a213eb472d5

tenfire commented 5 years ago

Ok, I got a little bit further this time:

18-12-03 20:57.41 DEBUG (MainThread) [volvooncall] Request for https://vocapi.wirelesscar.net/customerapi/rest/v3.0/engine/start
18-12-03 20:57.41 WARNING (MainThread) [volvooncall] Failure when communcating with the server: _request() got an unexpected keyword argument 'runtime'
18-12-03 20:57.41 WARNING (MainThread) [volvooncall] Failure to execute: _request() got an unexpected keyword argument 'runtime'