FilipDem / Domoticz-BMW-plugin

Domoticz plugin working with BMW Connected Drive
4 stars 2 forks source link

Cannot get the plugin working #14

Open wvdmaarl opened 1 year ago

wvdmaarl commented 1 year ago

Installed the newest plugin version and can login, but the data is not updated.

I have trouble finding the correct python modules. Have Domoticz 2022.2 with python 3.7.

Is it possible to state which plugin names the modules should be? queue en threading i cannot find at https://pypi.org/search same for json (or is this jsonlib-python3?).

pip3 list gives: Package Version


aiofile 3.8.1 anyio 3.6.1 asn1crypto 0.24.0 asyncio 3.4.3 bimmer-connected 0.12.0 caio 0.9.8 certifi 2022.12.7 charset-normalizer 2.0.8 cryptography 2.6.1 DateTime 4.3 datetime3 3.8.0 entrypoints 0.3 fail2ban 0.10.2 h11 0.12.0 httpcore 0.15.0 httpx 0.23.0 idna 3.4 jsonlib-python3 1.6.1 keyring 17.1.1 keyrings.alt 3.1.1 pip 18.1 pycrypto 2.6.1 pycryptodome 3.11.0 PyGObject 3.30.4 pyinotify 0.9.6 PyJWT 2.3.0 pytz 2021.1 pyxdg 0.25 requests 2.26.0 rfc3986 1.5.0 SecretStorage 2.3.1 setuptools 40.8.0 six 1.12.0 sniffio 1.3.0 systemd-python 234 thread6 0.2.0 typing-extensions 4.3.0 urllib3 1.24.1 urllib3-1-26-2 1.26.2.0 wheel 0.32.3 zope.interface 5.4.0

Thanks for your help

FilipDem commented 1 year ago

Hey, If I remember well the libraries are standard... I assume you don't get an error at startup, meaning that this should be OK. I upgraded a while ago to 2022,2 and all is still working. Do you have any error mentioned? Can you activate the debug logging and analyse what is happening? An idea is already to test it directly with bimmer_connected CLI... To be sure you get already all the info from bimmer_connected. Hope it helps & thanks, Filip

wvdmaarl commented 1 year ago

Thanks for your reply. Direct test with bimmer_connected does work. I get one error ('no attribute 'latitude'), see last line of the (anonimised) log output of Domoticz.

2023-01-31 16:54:08.401 BMW Connected: Device 5 Description: 2023-01-31 16:54:08.401 BMW Connected: Device 5 LastLevel: 0 2023-01-31 16:54:08.401 BMW Connected: Device 6 ID: 3555, Name: 'BMW i3 - Charging', nValue: 0, sValue: '0' 2023-01-31 16:54:08.401 BMW Connected: Device 6 DeviceID: 000A0006 2023-01-31 16:54:08.401 BMW Connected: Device 6 Description: 2023-01-31 16:54:08.401 BMW Connected: Device 6 LastLevel: 0 2023-01-31 16:54:08.401 BMW Connected: Device 7 ID: 3556, Name: 'BMW Connected - Charging time', nValue: 0, sValue: '' 2023-01-31 16:54:08.401 BMW Connected: Device 7 DeviceID: 000A0007 2023-01-31 16:54:08.401 BMW Connected: Device 7 Description: 2023-01-31 16:54:08.401 BMW Connected: Device 7 LastLevel: 0 2023-01-31 16:54:08.402 BMW Connected: Device 8 ID: 3557, Name: 'BMW i3 - Battery Level', nValue: 83, sValue: '83' 2023-01-31 16:54:08.402 BMW Connected: Device 8 DeviceID: 000A0008 2023-01-31 16:54:08.402 BMW Connected: Device 8 Description: 2023-01-31 16:54:08.402 BMW Connected: Device 8 LastLevel: 0 2023-01-31 16:54:08.402 BMW Connected: Device 9 ID: 3550, Name: 'BMW Connected - Remote Services', nValue: 0, sValue: '' 2023-01-31 16:54:08.402 BMW Connected: Device 9 DeviceID: 000A0009 2023-01-31 16:54:08.402 BMW Connected: Device 9 Description: 2023-01-31 16:54:08.402 BMW Connected: Device 9 LastLevel: 0 2023-01-31 16:54:08.403 BMW Connected: Device 10 ID: 3558, Name: 'BMW Connected - Car', nValue: 0, sValue: '0' 2023-01-31 16:54:08.403 BMW Connected: Device 10 DeviceID: 000A000A 2023-01-31 16:54:08.403 BMW Connected: Device 10 Description: 2023-01-31 16:54:08.403 BMW Connected: Device 10 LastLevel: 0 2023-01-31 16:54:08.403 BMW Connected: Device 11 ID: 3549, Name: 'BMW Connected - Mileage (Day)', nValue: 0, sValue: '45314' 2023-01-31 16:54:08.403 BMW Connected: Device 11 DeviceID: 000A000B 2023-01-31 16:54:08.403 BMW Connected: Device 11 Description: 2023-01-31 16:54:08.403 BMW Connected: Device 11 LastLevel: 0 2023-01-31 16:54:08.403 BMW Connected: Device 12 ID: 3559, Name: 'BMW Connected - Driving', nValue: 0, sValue: '' 2023-01-31 16:54:08.403 BMW Connected: Device 12 DeviceID: 000A000C 2023-01-31 16:54:08.404 BMW Connected: Device 12 Description: 2023-01-31 16:54:08.404 BMW Connected: Device 12 LastLevel: 0 2023-01-31 16:54:08.404 BMW Connected: Device 13 ID: 3560, Name: 'BMW Connected - Home', nValue: 0, sValue: '' 2023-01-31 16:54:08.404 BMW Connected: Device 13 DeviceID: 000A000D 2023-01-31 16:54:08.404 BMW Connected: Device 13 Description: 2023-01-31 16:54:08.404 BMW Connected: Device 13 LastLevel: 0 2023-01-31 16:54:08.404 BMW Connected: Looking for configuration file /home/pi/domoticz/plugins/Bmw/Bmw.json 2023-01-31 16:54:08.406 BMW Connected: Update BMW Connected - Mileage: nValue 45314 - sValue 45314 - Other: {'TimedOut': 1} 2023-01-31 16:54:08.406 (BMW Connected - Mileage) Updating device from 45314:'45314' to have values 45314:'45314'. 2023-01-31 16:54:08.424 BMW Connected: Update BMW Connected - Doors: nValue 0 - sValue 0 - Other: {'TimedOut': 1} 2023-01-31 16:54:08.424 (BMW Connected - Doors) Updating device from 0:'0' to have values 0:'0'. 2023-01-31 16:54:08.438 BMW Connected: Update BMW Connected - Windows: nValue 0 - sValue 0 - Other: {'TimedOut': 1} 2023-01-31 16:54:08.438 (BMW Connected - Windows) Updating device from 0:'0' to have values 0:'0'. 2023-01-31 16:54:08.452 BMW Connected: Update BMW Connected - Remain mileage (fuel): nValue 0 - sValue - Other: {'TimedOut': 1} 2023-01-31 16:54:08.452 (BMW Connected - Remain mileage (fuel)) Updating device from 0:'' to have values 0:''. 2023-01-31 16:54:08.462 BMW Connected: Update BMW Connected - Remain mileage (elec): nValue 225 - sValue 225 - Other: {'TimedOut': 1} 2023-01-31 16:54:08.463 (BMW Connected - Remain mileage (elec)) Updating device from 225:'225' to have values 225:'225'. 2023-01-31 16:54:08.473 BMW Connected: Update BMW i3 - Charging: nValue 0 - sValue 0 - Other: {'TimedOut': 1} 2023-01-31 16:54:08.473 (BMW i3 - Charging) Updating device from 0:'0' to have values 0:'0'. 2023-01-31 16:54:08.494 BMW Connected: Update BMW Connected - Charging time: nValue 0 - sValue - Other: {'TimedOut': 1} 2023-01-31 16:54:08.494 (BMW Connected - Charging time) Updating device from 0:'' to have values 0:''. 2023-01-31 16:54:08.504 BMW Connected: Update BMW i3 - Battery Level: nValue 83 - sValue 83 - Other: {'TimedOut': 1} 2023-01-31 16:54:08.505 (BMW i3 - Battery Level) Updating device from 83:'83' to have values 83:'83'. 2023-01-31 16:54:08.537 BMW Connected: Update BMW Connected - Remote Services: nValue 0 - sValue - Other: {'TimedOut': 1} 2023-01-31 16:54:08.537 (BMW Connected - Remote Services) Updating device from 0:'' to have values 0:''. 2023-01-31 16:54:08.565 BMW Connected: Update BMW Connected - Car: nValue 0 - sValue 0 - Other: {'TimedOut': 1} 2023-01-31 16:54:08.566 (BMW Connected - Car) Updating device from 0:'0' to have values 0:'0'. 2023-01-31 16:54:08.600 BMW Connected: Update BMW Connected - Mileage (Day): nValue 0 - sValue 45314 - Other: {'TimedOut': 1} 2023-01-31 16:54:08.600 (BMW Connected - Mileage (Day)) Updating device from 0:'45314' to have values 0:'45314'. 2023-01-31 16:54:08.621 BMW Connected: Update BMW Connected - Driving: nValue 0 - sValue - Other: {'TimedOut': 1} 2023-01-31 16:54:08.621 (BMW Connected - Driving) Updating device from 0:'' to have values 0:''. 2023-01-31 16:54:08.635 BMW Connected: Update BMW Connected - Home: nValue 0 - sValue - Other: {'TimedOut': 1} 2023-01-31 16:54:08.635 (BMW Connected - Home) Updating device from 0:'' to have values 0:''. 2023-01-31 16:54:08.658 BMW Connected: Entering tasks handler 2023-01-31 16:54:08.659 BMW Connected: Acquiring GIL for 'onStartCallback' 2023-01-31 16:54:08.659 BMW Connected: Handling task: Login. 2023-01-31 16:54:08.661 BMW Connected: Login done! MyBMW object: MyBMWAccount(username='xxxxxxxx@xxxx.xxxx', region=<Regions.REST_OF_WORLD: 'row'>, config=MyBMWClientConfiguration(authentication=<bimmer_connected.api.authentication.MyBMWAuthentication object at 0x66b23b90>, log_responses=False, observer_position=None, use_metric_units=True), vehicles=[]) 2023-01-31 16:54:08.377 Status: BMW Connected: Initialized version 3.2.2, author 'Filip Demaertelaere' 2023-01-31 16:54:36.004 Status: BMW Connected: Login successful! Car i3 120 (VIN:XYZ00000000000) found! 2023-01-31 16:54:36.166 Error: BMW Connected: General error TaskHandler: 'NoneType' object has no attribute 'latitude'

Every 10 seconds I get an onHeartbeatcall: 2023-01-31 16:58:33.000 BMW Connected: Pushing 'onHeartbeatCallback' on to queue 2023-01-31 16:58:33.050 BMW Connected: Processing 'onHeartbeatCallback' message 2023-01-31 16:58:33.050 BMW Connected: Acquiring GIL for 'onHeartbeatCallback' 2023-01-31 16:58:33.051 BMW Connected: Calling message handler 'onHeartbeat' on 'module' type object. 2023-01-31 16:58:33.051 BMW Connected: Acquiring GIL for 'onHeartbeatCallback'

But apparently without any updating of the values.

I will recheck if all Python modules of bimmer_connected and the domoticz plugin work. But may be you have other possible solutions.

Thanks again.

Wim

FilipDem commented 1 year ago

Hi Wim,

Well, I would advice to put first in comment the part of the geolocalisation (line 400-408 of plugin.py). This should avoid the problem with the latitude and see if we get a step further. I am wondering why you dont have the vehicle_location object from the bimmer_connected. But we can look at this problem in a next step. Let us first get the basics working.

That there is every 10 seconds the onHeartbeatcallback is normal... However BMW updates are not that fast as it will block your account otherwise. So in the hardware settings, it defines the interval time to update the BMW data... But again, I want to get rid of the latitude error to be sure it has no impact... So please put it in comments and give it another try (sorry).

F

wvdmaarl commented 1 year ago

Hi Filip,

Thanks for your reply. I have outcommented line 400-408 of plugin.py. I don't receive the latitude error anymore. I rechecked the modules via python3 command line. All modules are imported without error. I checked bimmerconnected cli. In the output at the line with location it gives 'null'. However, with a interval time set at 5 minutes, it first i had still no updates, only at the first start of the plugin. But right now (an hour later) it is actually updating! So far so good.

Appartently the outcommenting fixed it. Thanks!

Wim

FilipDem commented 1 year ago

Hi Wim,

nice to hear... Yesterday I had no time (I have also a professional life ;-)) yet to check and wanted to investigate today. Glad to hear that it is working. I cannot explain why it would not work before the one hour timeframe... But correct that I don't look for the data immediately after the start of the plugin.

About the location, I am using this features to detect when I am coming home to activate already smart device (opening the gate, de-activating the alarm etc)... Don't know why this is null at your side. Perhaps a setting of your car/app to allow tracking of the location?

I will make a new version that takes into account that the location could be absent. I can do this without analysis (checking on null), however it would be better to see if there is sth that indicates that location is deactivated. For this you can help me giving a dump of the car info (you can mask confidential info if you want).

Again, not mandatory to do it, but could help to find a good check on the location availability.

Just add the following lines ...

with open('{}Bmw_info.txt'.format(Parameters['HomeFolder']), "w") as myfile:
    myfile.write('{}'.format(self.myVehicle))

... between the 2 lines of code (so on line 302) ...

self.myVehicle = self.myBMW.get_vehicle(Parameters['Mode4'])
if self.myVehicle:

... and send me the file Bmw_info.txt in the plugin directory.

wvdmaarl commented 1 year ago

Hi Filip,

It seems that indeed the location sharing in my car is disabled recently (I just checked). So probably it will state the location if I enable that. Hereby I share the output of bimmerconnected with my BMW i3:

Found 1 vehicles: i3 120 VIN: XYZ0000000000 Mileage: XXXXX km Vehicle data: [ { "data": { "vin": "XYZ0000000000", "mappingInfo": { "isAssociated": false, "isLmmEnabled": false, "mappingStatus": "CONFIRMED", "isPrimaryUser": true }, "appVehicleType": "CONNECTED", "attributes": { "lastFetched": "2023-02-03T10:48:39.465Z", "model": "i3 120", "year": 2019, "color": 4282731373, "brand": "BMW_I", "driveTrain": "ELECTRIC", "headUnitType": "NBT_EVO", "headUnitRaw": "NBTEVO", "hmiVersion": "ID5", "softwareVersionCurrent": { "puStep": { "month": 11, "year": 19 }, "iStep": 520, "seriesCluster": "I001" }, "softwareVersionExFactory": { "puStep": { "month": 11, "year": 19 }, "iStep": 520, "seriesCluster": "I001" }, "telematicsUnit": "ATM1", "bodyType": "I01", "countryOfOrigin": "NL", "driverGuideInfo": { "androidAppScheme": "com.bmwgroup.driversguide.row", "iosAppScheme": "bmwdriversguide:///open", "androidStoreUrl": "https://play.google.com/store/apps/details?id=com.bmwgroup.driversguide.row", "iosStoreUrl": "https://apps.apple.com/de/app/id714042749?mt=8" } }, "is_metric": true, "fetched_at": "2023-02-03T10:48:22.532285+00:00", "state": { "isLeftSteering": true, "lastFetched": "2023-02-03T10:48:48.716Z", "lastUpdatedAt": "2023-02-02T21:58:38Z", "isLscSupported": true, "range": 244, "doorsState": { "combinedSecurityState": "SECURED", "leftFront": "CLOSED", "leftRear": "CLOSED", "rightFront": "CLOSED", "rightRear": "CLOSED", "combinedState": "CLOSED", "hood": "CLOSED", "trunk": "CLOSED" }, "windowsState": { "leftFront": "CLOSED", "rightFront": "CLOSED", "combinedState": "CLOSED" }, "currentMileage": 45620, "requiredServices": [ { "dateTime": "2023-11-01T00:00:00.000Z", "type": "BRAKE_FLUID", "status": "OK", "description": "Next service due by the specified date." }, { "dateTime": "2023-11-01T00:00:00.000Z", "type": "VEHICLE_CHECK", "status": "OK", "description": "Next vehicle check due after the specified distance or date." }, { "dateTime": "2023-11-01T00:00:00.000Z", "type": "VEHICLE_TUV", "status": "OK", "description": "Next state inspection due by the specified date." } ], "checkControlMessages": [], "chargingProfile": { "chargingControlType": "WEEKLY_PLANNER", "reductionOfChargeCurrent": { "start": { "hour": 23, "minute": 5 }, "end": { "hour": 7, "minute": 30 } }, "chargingMode": "IMMEDIATE_CHARGING", "chargingPreference": "CHARGING_WINDOW", "departureTimes": [ { "id": 1, "timeStamp": { "hour": 12, "minute": 10 }, "action": "DEACTIVATE", "timerWeekDays": [ "MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY" ] }, { "id": 2, "timeStamp": { "hour": 14, "minute": 30 }, "action": "DEACTIVATE", "timerWeekDays": [ "MONDAY", "TUESDAY", "WEDNESDAY" ] }, { "id": 3, "timeStamp": { "hour": 14, "minute": 0 }, "action": "DEACTIVATE", "timerWeekDays": [] }, { "id": 4, "action": "DEACTIVATE", "timerWeekDays": [] } ], "climatisationOn": false, "chargingSettings": { "targetSoc": 100, "idcc": "NO_ACTION", "hospitality": "NO_ACTION" } }, "electricChargingState": { "chargingLevelPercent": 90, "range": 244, "isChargerConnected": false, "chargingStatus": "INVALID", "chargingTarget": 100 }, "combustionFuelLevel": {}, "driverPreferences": { "lscPrivacyMode": "OFF" }, "climateTimers": [ { "isWeeklyTimer": false, "timerAction": "DEACTIVATE", "timerWeekDays": [], "departureTime": { "hour": 7, "minute": 0 } }, { "isWeeklyTimer": true, "timerAction": "DEACTIVATE", "timerWeekDays": [ "MONDAY" ], "departureTime": { "hour": 7, "minute": 0 } }, { "isWeeklyTimer": true, "timerAction": "DEACTIVATE", "timerWeekDays": [ "MONDAY" ], "departureTime": { "hour": 7, "minute": 0 } } ] }, "capabilities": { "a4aType": "USB_ONLY", "climateNow": true, "climateFunction": "AIR_CONDITIONING", "horn": true, "isBmwChargingSupported": true, "isCarSharingSupported": false, "isChargeNowForBusinessSupported": false, "isChargingHistorySupported": true, "isChargingHospitalityEnabled": false, "isChargingLoudnessEnabled": false, "isChargingPlanSupported": true, "isChargingPowerLimitEnabled": false, "isChargingSettingsEnabled": false, "isChargingTargetSocEnabled": false, "isCustomerEsimSupported": false, "isDataPrivacyEnabled": false, "isDCSContractManagementSupported": true, "isEasyChargeEnabled": false, "isMiniChargingSupported": false, "isEvGoChargingSupported": false, "isRemoteHistoryDeletionSupported": false, "isRemoteEngineStartSupported": false, "isRemoteServicesActivationRequired": false, "isRemoteServicesBookingRequired": false, "isScanAndChargeSupported": true, "lastStateCallState": "ACTIVATED", "lights": true, "lock": true, "sendPoi": true, "unlock": true, "vehicleFinder": false, "vehicleStateSource": "LAST_STATE_CALL", "isRemoteHistorySupported": true, "isWifiHotspotServiceSupported": false, "isNonLscFeatureEnabled": false, "isSustainabilitySupported": false, "isSustainabilityAccumulatedViewEnabled": false, "checkSustainabilityDPP": false, "specialThemeSupport": [], "isRemoteParkingSupported": false, "remoteChargingCommands": {}, "isClimateTimerWeeklyActive": false, "digitalKey": { "bookedServicePackage": "NONE", "state": "NOT_AVAILABLE" } } }, "fuel_and_battery": { "remaining_range_fuel": [ null, null ], "remaining_range_electric": [ 244, "km" ], "remaining_range_total": [ 244, "km" ], "remaining_fuel": [ null, null ], "remaining_fuel_percent": null, "remaining_battery_percent": 90, "charging_status": "NOT_CHARGING", "charging_start_time_no_tz": null, "charging_end_time": null, "is_charger_connected": false, "account_timezone": "CET", "charging_start_time": null }, "vehicle_location": { "location": null, "heading": null, "vehicle_update_timestamp": "2023-02-03T10:48:48+00:00", "account_region": "row", "remote_service_position": null }, "doors_and_windows": { "door_lock_state": "SECURED", "lids": [ { "name": "leftFront", "state": "CLOSED", "is_closed": true }, { "name": "leftRear", "state": "CLOSED", "is_closed": true }, { "name": "rightFront", "state": "CLOSED", "is_closed": true }, { "name": "rightRear", "state": "CLOSED", "is_closed": true }, { "name": "hood", "state": "CLOSED", "is_closed": true }, { "name": "trunk", "state": "CLOSED", "is_closed": true } ], "windows": [ { "name": "leftFront", "state": "CLOSED", "is_closed": true }, { "name": "rightFront", "state": "CLOSED", "is_closed": true } ], "all_lids_closed": true, "all_windows_closed": true, "open_lids": [], "open_windows": [] }, "condition_based_services": { "messages": [ { "service_type": "BRAKE_FLUID", "state": "OK", "due_date": "2023-11-01T00:00:00+00:00", "due_distance": [ null, null ] }, { "service_type": "VEHICLE_CHECK", "state": "OK", "due_date": "2023-11-01T00:00:00+00:00", "due_distance": [ null, null ] }, { "service_type": "VEHICLE_TUV", "state": "OK", "due_date": "2023-11-01T00:00:00+00:00", "due_distance": [ null, null ] } ], "is_service_required": false }, "check_control_messages": { "messages": [], "has_check_control_messages": false }, "charging_profile": { "is_pre_entry_climatization_enabled": false, "timer_type": "WEEKLY_PLANNER", "departure_times": [ { "_timer_dict": { "id": 1, "timeStamp": { "hour": 12, "minute": 10 }, "action": "DEACTIVATE", "timerWeekDays": [ "MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY" ] }, "action": "DEACTIVATE", "start_time": "12:10:00", "timer_id": 1, "weekdays": [ "MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY" ] }, { "_timer_dict": { "id": 2, "timeStamp": { "hour": 14, "minute": 30 }, "action": "DEACTIVATE", "timerWeekDays": [ "MONDAY", "TUESDAY", "WEDNESDAY" ] }, "action": "DEACTIVATE", "start_time": "14:30:00", "timer_id": 2, "weekdays": [ "MONDAY", "TUESDAY", "WEDNESDAY" ] }, { "_timer_dict": { "id": 3, "timeStamp": { "hour": 14, "minute": 0 }, "action": "DEACTIVATE", "timerWeekDays": [] }, "action": "DEACTIVATE", "start_time": "14:00:00", "timer_id": 3, "weekdays": [] }, { "_timer_dict": { "id": 4, "action": "DEACTIVATE", "timerWeekDays": [] }, "action": "DEACTIVATE", "start_time": null, "timer_id": 4, "weekdays": [] } ], "preferred_charging_window": { "_window_dict": { "start": { "hour": 23, "minute": 5 }, "end": { "hour": 7, "minute": 30 } }, "end_time": "07:30:00", "start_time": "23:05:00" }, "charging_preferences": "CHARGING_WINDOW", "charging_mode": "IMMEDIATE_CHARGING" }, "available_attributes": [ "gps_position", "vin", "remaining_range_total", "mileage", "charging_time_remaining", "charging_end_time", "charging_time_label", "charging_status", "connection_status", "remaining_battery_percent", "remaining_range_electric", "last_charging_end_result", "condition_based_services", "check_control_messages", "door_lock_state", "timestamp", "lids", "windows" ], "brand": "bmw", "drive_train": "ELECTRIC", "drive_train_attributes": [ "remaining_range_total", "mileage", "charging_time_remaining", "charging_end_time", "charging_time_label", "charging_status", "connection_status", "remaining_battery_percent", "remaining_range_electric", "last_charging_end_result" ], "has_combustion_drivetrain": false, "has_electric_drivetrain": true, "is_charging_plan_supported": true, "is_lsc_enabled": true, "is_vehicle_active": false, "is_vehicle_tracking_enabled": false, "lsc_type": "ACTIVATED", "mileage": [ 45620, "km" ], "name": "i3 120", "timestamp": "2023-02-03T10:48:48+00:00", "vin": "XYZ000000000" } ]

Question/request: I found out that currently it is only possible to check the charging status and not change it via Domoticz. In the former version (before the API overhaul) it was possible the start and stop charging via Domoticz. Right now I have two scripts (first script: solar charging, only charge when solar panels are above a certain output, second script: charge not further than 80% to prolonge battery life). But right now I need to manually adjust it or via de BMW App. Is it doable to add starting and stopping charging via the plugin?

Thanks again.

Wim

FilipDem commented 1 year ago

OK. Thanks for the info! Will take a look (but I am really convinced when you activate localisation it should work).

Wrt charging, it was possible in the past but at a certain moment no longer supported... I looked to bimmer_connected now and saw an additional remote service "charge now". This should be easy to integrate in my implementation...

However I see that the remote service "charge now" is not available in bimmer_connected CLI? I don't have an electric car :-( (yet). I can update the plugin and send you a version to see if it is working... Please read also discussion (I have nothing in the plugin to manage the charging profiles).

I cannot promise it will be done the next some days...

F

wvdmaarl commented 1 year ago

Hi Filip,

The link to the discussion on charging via Home Assistant is a similar request. For now in the MyBMW App you can't toggle between charge on and off, but you can toggle between direct charging and charging during a period. If it is possible to toggle between that via Domoticz it would be very helpful. I haven't checked whether this is possible via bimmerconnected CLI. In that case it could also work via a bash script.

Thanks again for your help. I am not in a hurry. I would already be grateful if you want to spend some time on it.

greets, Wim.

FilipDem commented 1 year ago

Hi Wim, Please find in attachment an update of the plugin.py. I check now on the availability of the location information. I cannot guarantee if it works as it is always available with my car... If it gives again a problem, please put it again in comments.

I also added a remote_service "charge_now"... I tested so far as I could... It ended up with an error of course that this service is not support by my (combustible) car :-). I would say, give it a try and let me know...

plugin.py.txt

Success!

Filip

wvdmaarl commented 1 year ago

Hi Filip,

Thanks for the new version. I have checked it and it works without the latitude error.

However, the charge modus isn't changed with the 'charge_now' line added. So it doesn't work yet.

I am not sure it should be defined as charge_now, since with the new BMW app you can only switch between Charging Immediately and 'Charge in Window', see also the discussion at bimmerconnected: https://github.com/bimmerconnected/bimmer_connected/discussions/440

highlighted this response:

"Just to clarify that this is not about the remote service 'charge_now'. The request is about controlling the ChargingMode as modeled in https://github.com/bimmerconnected/bimmer_connected/blob/master/bimmer_connected/vehicle/charging_profile.py The BMW app allows for switching between IMMEDIATE_CHARGING and DELAYED_CHARGING, whereby the latter is controlled by a user-defined CHARGING_WINDOW (to set for example your local reduced energy-price timeframe.) I'd be happy to supply information or run tests using my PHEV."

Edit: I updated right now to Bimmerconnected_0.12.1 which seems to have incorporated charging_profile.py so it seems functionality is available, may be even Soc Charge state (to monitor battery degradation), see https://github.com/bimmerconnected/bimmer_connected/pull/516.

Thanks again for your help.

Wim

FilipDem commented 1 year ago

I investigated a bit today... However I don't figure out yet how to start the charging. I see indeed the changes, but still don't capture how to send the settings to the car... Unfortunately the HA component is not yet adapted to start charging, otherwise this would be an inspiration how to do...

Currently I have a small python script to test outside Domoticz first... Just need to see how we send the IMMEDIATE_CHARGING status to the car using bimmer_connected. I will perhaps post a question in the bimmer_connected Github.

Keep you informed.

Kr,

F

https://github.com/bimmerconnected/bimmer_connected/discussions/440

FilipDem commented 1 year ago

Don't know if you followed it on bimmer_connected. But it is indeed confirmed that the library doesn't support (yet) the start of charging. The commits done so far are adding attributes to the library. From Gerard: "The options to start and stop charging via the lib are not available at the moment. This PR adds some attributes which will be shown in Home Assistant". We'll need to keep an eye on the following commits to see when it would be ready. Thanks, Filip

FilipDem commented 1 year ago

I have seen a new beta version if bimmer_connected supporting starting and stopping of charging for EVs. Before integrating in the Domoticz plugin, I would like to test it outside Domoticz. Could you give this a try, please? The python script should give the status, horn, start charging and stop charging in sequence. Possibly you can comment out the stop charging and see that the car remains charging... If this works for you, I will integrate it in Domoticz (both start and stop). This should not be too much work. Thanks for feedback.

Install the beta bimmer_connected with sudo pip3 install bimmer_connected==0.13.0b1. !! Before executing, update the script with your USERNAME, PASSWORD and VIN. You will see it at the beginning of the file.

test_charge.py.txt

subtrEM commented 1 year ago

FWIW, just a note: bimmerconnected 0.13.0b1 release note states:

All remote services have been refactored to include checks against the vehicle capabilities (provided in the state API). If your vehicle does not support a service, a ValueError will be raised. For example, not all EVs will support charging start/stop - it seems that you need an ID8 head unit for this (e.g. i4, i7, iX, but not iX3).

This means the EV trigger_charge_start() and trigger_charge_stop() functions will only work with select models - in particular not the i3.

FilipDem commented 1 year ago

Seen your comment, I suppose you have an i3 :-(. Sorry...

subtrEM commented 1 year ago

Well, it's actually because Wim wvdmaarl seemingly has one, that's why i mention it :-)

wvdmaarl commented 1 year ago

Thanks for finding out. I have indeed an i3, but will try it anyway, when I have time.