Closed jackmcdougal closed 6 years ago
The door and windows binary sensors works that way, take a look at them. However, for tyre pressure, I guess 4 sensors should be created, one per wheel, and that requires some additional code in the sensor setup function. In sensor/volvooncall.py you have to make a special case for the case when the sensor is the tyrepressure and instead of one sensor, you create four, one for each wheel. Is it mainly the wheel pressures you feel are missing from the current available sensors?
Thanks for the reply! Yes, most of what I would like to add are additional sensors - not a single result based on interpreting nested data (like doors and windows). The main ones I am looking to get are related to Battery status (hvbattery) ... Looking at the log, nested components on my 2016 vehicle are:
I can see a way to use regex to grab one nested sensor ... but don't think this can scale to more than one per parent. I will take a look at tellduslive.py. Thanks for the insight!
sorry, I meant sensor/volvooncall.py
so, for each sensor you would like to add - can you please post exactly (please mask any sensitive data) what it looks like in the server output JSON (from the root node), and how you would like it to be presented in HA, then maybe we can work it out together somehow. I don't seem to have access too all attributes in my account.
Hi Erik, Sorry for the delay. Been travelling and no time to work on this.
Below is 2 sections: 1rst is metadata about car; 2nd is sensor data. I've tried to format so the nested sections are separate/easier to locate. To summarize, this is what I think would be useful to add:
Sensors Nested within an additional layer of {}:
'hvBatteryChargeStatus': 'PlugRemoved' 'hvBatteryChargeStatusDerived': 'CableNotPluggedInCar', 'timeToHVBatteryFullyCharged': 300, 'distanceToHVBatteryEmpty': None, 'hvBatteryChargeWarning': 'UnexpectedPowerloss' 'hvBatteryChargeModeStatus': None, 'hvBatteryLevel': 100,
Sensors the same as existing:
'averageFuelConsumption': 58.0, ## needs a divide by 100 like odometer 'connectionStatus': 'Disconnected', ## only if 'highVoltageBatterySupported': True 'engineRunning': False, ## only if'engineStartSupported': True 'distanceToEmpty': 260, 'averageSpeed': 36, 'remoteClimatizationStatus': 'NoCableConnected', ## only if 'preclimatizationSupported': True 'serviceWarningStatus': 'Normal',
I think I can successfully add the un-nested sensors - haven't figured out the "only if" part yet. Not too sure on approach for the nested ones - where more than one sensor needs to be created.
Below is the full output in debug mode. (is this what you were looking for?)
Thanks for the help!
017-12-01 19:52:14 DEBUG (Thread-42) [volvooncall] Received {'unlockTimeFrame': 120, 'vehiclePlatform': '2421', 'fuelTankVolume': 50, 'engineStartSupported': True, 'honkAndBlinkVersionsSupported': ['honkAndOrBlink', 'honkAndBlink'], 'numberOfDoors': 5, 'honkAndBlinkSupported': True, 'timeFullyAccessible': 7200, 'tyreDimensionCode': '2421R509', 'serverVersion': '4.12.43-voc-deployable', 'vehicleTypeCode': 'redacted_code', 'status.parkedIndoor.supported': False, 'carLocatorSupported': True, 'subscriptionEndDate': datetime.datetime(2010, 10, 10, 22, 36, 52, tzinfo=datetime.timezone.utc), 'subscriptionType': 'PREMIUM_1923', 'vehicleType': 'XC90', 'journalLogSupported': False, 'gearboxCode': '2411XB02', 'exteriorCode': '2411110C', 'modelYear': 2016, 'lockSupported': True, 'maxActiveDelayChargingLocations': 7, 'tyreInflationPressureHeavyCode': None, 'subscriptionStartDate': datetime.datetime(2010, 10, 10, 12, 0, tzinfo=datetime.timezone.utc), 'highVoltageBatterySupported': True, 'interiorCode': '24211005', 'assistanceCallSupported': True, 'vin': 'redacted_vin', 'timePartiallyAccessible': 31680, 'fuelType': 'HEV', 'sendPOIToVehicleVersionsSupported': ['sendSinglePOIToVehicle'], 'climatizationCalendarMaxTimers': 8, 'honkAndBlinkDistance': 500, 'registrationNumber': None, 'grossWeight': 3010, 'remoteHeaterSupported': False, 'verificationTimeFrame': 120, 'unlockSupported': True, 'carLocatorDistance': 1000, 'engineCode': 'redacted_enginecode', 'bCallAssistanceNumber': '+199_redacted_phone', 'journalLogEnabled': True, 'VIN': 'redacted_vin', 'climatizationCalendarVersionsSupported': ['climatizationCalendarV1'], 'preclimatizationSupported': True, 'overrideDelayChargingSupported': False, 'tyreInflationPressureLightCode': None,
'country': {'iso2': 'ZB'}}
2017-12-01 19:52:14 DEBUG (Thread-42) [volvooncall] Received {'fuelAmountLevel': 72, 'tripMeter2': 0, 'averageFuelConsumptionTimestamp': datetime.datetime(2017, 12, 1, 22, 12, 28, tzinfo=datetime.timezone.utc), 'bulbFailures': [], 'washerFluidLevel': 'Normal',
'windows': {'frontRightWindowOpen': False, 'rearRightWindowOpen': False, 'frontLeftWindowOpen': False, 'rearLeftWindowOpen': False, 'timestamp': datetime.datetime(2017, 12, 1, 22, 12, 28, tzinfo=datetime.timezone.utc)},
'tripMeter1': 6161900,
'hvBattery': {'hvBatteryLevelTimestamp': datetime.datetime(2017, 12, 1, 22, 12, 35, tzinfo=datetime.timezone.utc), 'hvBatteryChargeStatusDerivedTimestamp': datetime.datetime(2017, 12, 1, 22, 12, 35, tzinfo=datetime.timezone.utc), 'hvBatteryChargeStatus': 'PlugRemoved', 'timeToHVBatteryFullyCharged': 300, 'distanceToHVBatteryEmpty': None, 'distanceToHVBatteryEmptyTimestamp': datetime.datetime(2017, 12, 1, 22, 12, 35, tzinfo=datetime.timezone.utc), 'hvBatteryChargeStatusTimestamp': datetime.datetime(2017, 12, 1, 22, 8, 15, tzinfo=datetime.timezone.utc), 'hvBatteryChargeWarning': 'UnexpectedPowerloss', 'hvBatteryChargeStatusDerived': 'CableNotPluggedInCar', 'timeToHVBatteryFullyChargedTimestamp': datetime.datetime(2017, 12, 1, 0, 20, 14, tzinfo=datetime.timezone.utc), 'hvBatteryChargeModeStatus': None, 'hvBatteryLevel': 100, 'hvBatteryChargeModeStatusTimestamp': None, 'hvBatteryChargeWarningTimestamp': datetime.datetime(2017, 11, 30, 3, 9, 33, tzinfo=datetime.timezone.utc)},
'washerFluidLevelTimestamp': datetime.datetime(2017, 12, 1, 22, 12, 28, tzinfo=datetime.timezone.utc), 'averageFuelConsumption': 58.0, 'distanceToEmptyTimestamp': datetime.datetime(2017, 12, 1, 22, 12, 28, tzinfo=datetime.timezone.utc), 'odometer': 1161572, 'connectionStatus': 'Disconnected', 'bulbFailuresTimestamp': datetime.datetime(2017, 12, 1, 22, 12, 28, tzinfo=datetime.timezone.utc), 'odometerTimestamp': datetime.datetime(2017, 12, 1, 22, 12, 28, tzinfo=datetime.timezone.utc), 'remoteClimatizationStatusTimestamp': datetime.datetime(2017, 12, 1, 22, 12, 35, tzinfo=datetime.timezone.utc), 'carLockedTimestamp': datetime.datetime(2017, 12, 1, 22, 12, 28, tzinfo=datetime.timezone.utc), 'engineRunning': False, 'distanceToEmpty': 260, 'fuelAmount': 36, 'timePartiallyAccessibleUntil': datetime.datetime(2017, 12, 23, 22, 11, 26, tzinfo=datetime.timezone.utc), 'tripMeter1Timestamp': datetime.datetime(2017, 12, 1, 22, 12, 28, tzinfo=datetime.timezone.utc), 'brakeFluid': 'Normal',
'doors': {'hoodOpen': False, 'frontLeftDoorOpen': False, 'timestamp': datetime.datetime(2017, 12, 1, 22, 12, 28, tzinfo=datetime.timezone.utc), 'frontRightDoorOpen': False, 'rearLeftDoorOpen': False, 'tailgateOpen': False, 'rearRightDoorOpen': False},
'tripMeter2Timestamp': datetime.datetime(2017, 12, 1, 22, 12, 28, tzinfo=datetime.timezone.utc), 'averageSpeed': 36, 'serviceWarningStatusTimestamp': datetime.datetime(2017, 12, 1, 22, 12, 28, tzinfo=datetime.timezone.utc), 'engineRunningTimestamp': datetime.datetime(2017, 12, 1, 22, 12, 28, tzinfo=datetime.timezone.utc), 'fuelAmountTimestamp': datetime.datetime(2017, 12, 1, 22, 12, 28, tzinfo=datetime.timezone.utc),
'heater': {'timer1': {'time': None, 'state': None}, 'timestamp': datetime.datetime(2017, 11, 26, 14, 27, 25, tzinfo=datetime.timezone.utc), 'status': 'off', 'timer2': {'time': None, 'state': None}, 'seatSelection': {'rearMid': False, 'frontPassengerSide': False, 'frontDriverSide': False, 'rearDriverSide': False, 'rearPassengerSide': False}},
'brakeFluidTimestamp': datetime.datetime(2017, 12, 1, 22, 12, 28, tzinfo=datetime.timezone.utc), 'carLocked': True, 'remoteClimatizationStatus': 'NoCableConnected', 'serviceWarningStatus': 'Normal', 'averageSpeedTimestamp': datetime.datetime(2017, 12, 1, 22, 12, 28, tzinfo=datetime.timezone.utc), 'fuelAmountLevelTimestamp': datetime.datetime(2017, 12, 1, 22, 12, 28, tzinfo=datetime.timezone.utc), 'timeFullyAccessibleUntil': datetime.datetime(2017, 12, 6, 22, 11, 26, tzinfo=datetime.timezone.utc),
'tyrePressure': {'frontRightTyrePressure': 'Normal', 'timestamp': datetime.datetime(2017, 12, 1, 22, 12, 28, tzinfo=datetime.timezone.utc), 'rearLeftTyrePressure': 'Normal', 'rearRightTyrePressure': 'Normal', 'frontLeftTyrePressure': 'Normal'},
'ERS': {'engineStartWarningTimestamp': datetime.datetime(2017, 11, 30, 12, 50, 29, tzinfo=datetime.timezone.utc), 'timestamp': datetime.datetime(2017, 11, 30, 12, 50, 29, tzinfo=datetime.timezone.utc), 'engineStartWarning': 'None', 'status': 'off'},
'connectionStatusTimestamp': datetime.datetime(2017, 12, 1, 22, 12, 35, tzinfo=datetime.timezone.utc)}
5 months later ... is this still of interest or did you solve it yourself somehow?
Hello,
I am also looking into the request made by @JC-Mac. I also want to automate some more in my HomeAssistant for my Volvo (example: when volvo is charged, let Google Home tell me :) )
Any updates on the questions above?
Personally (I wrote the Home Assistant VOC component as well), I have migrated to using MQTT (https://github.com/molobrakos/volvooncall/blob/master/mqtt.py) to integrate VOC with Home Assistant. This makes it easier to try out and add new things without touching the HA source. Of course I would approve/accept any PR adding this functionality either in HA or the VOC library.
I added extraction of the properties for tyre pressure and battry status. Please see here: https://github.com/molobrakos/volvooncall/blob/master/dashboard.py#L321
Please test (on command line ./voc -vv dashboard
and please contribute any fixes if it is not working as expected.
When this seems to be in place, I will integrate this into Home Assistant (by letting HA iterate of the Instruments available instead of using the raw json data).
@JC-Mac @armand-janssen
Hi. Im a total noob at Python but i managed to test Volvooncall from your Github. No errors in output found.
However i have some issues with the data:
The Battery Charging output is wrong and should read from 'hvBatteryChargeStatusDerived': 'CablePluggedInCar_Charging'. The current output shows charging even when interupted.
The output REGNR Battery Range: 180 minutes is not a range. It is how long til battery is fully charged. I assume that is timeToHVBatteryFullyCharged': 180
Missing lock status 'carLocked': False
Missing a setting for preclimate 'parkedIndoor': True'
I hope this helps since I would love this info in HA.
Feel free to ask if anything is unclear.
I have no idea how to implement the changes ....
Your work is appreciated @molobrakos
I believe 1 and 2 might be fixed now in https://github.com/molobrakos/volvooncall/commit/7441c2f55d4baa92c14ef054a14c3293a8595bee I am not sure what you mean by 3 and 4 can you please elaborate?
Sorry, it sounded clear in my head last night. 3 and 4 are read as inputs from voc but missing as data outputs ( as read in the big bunch of data presented when running ./voc -vv dashboard)
I hope this makes it clear and I hope I havent missunderstood anything.
3) Maybe you can try the latest version. It sounds strange. 4) How should it be interpreted, just as a binary sensor with true=ok, false=not ok? My car reports
"parkedIndoor": null,
"parkedIndoorTimestamp": null,
"status.parkedIndoor.supported": false,
Closing this for now. Please open separate pull requests for any missing properties/resources.
Any update to Hassocks yet, id love to see some additional properties of the car such as charging and fuel levels. Thanks
I'm missing the trunk in Home Assistant. Of course, if doors indicates open and front and rear doors are closed as well as the hood, it's easy to presume that it is the trunk. I've done this in a template sensor, but unfortunately I lost the template while re-organizing.
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)},
...