Issue fixed in 0.0.5 - https://github.com/FlyingDiver/Indigo-B ... /tag/0.0.5
The plugin now handles arrays in the vehicle data properly.
Also submitted to plugin store.
Feb 25, 2020 at 8:06:12 AM
Reloading plugin "BMW Connected Drive 0.0.5"
Stopping plugin "BMW Connected Drive 0.0.5" (pid 667)
Stopped plugin "BMW Connected Drive 0.0.5"
Starting plugin "BMW Connected Drive 0.0.5" (pid 74243)
Started plugin "BMW Connected Drive 0.0.5"
BMW Connected Drive Error Error in plugin execution runConcurrentThread:
Traceback (most recent call last):
File "plugin.py", line 139, in runConcurrentThread
File "plugin.py", line 176, in updateVehicle
File "/Library/Application Support/Perceptive Automation/Indigo 7.4/Plugins/BMW ConnectedDrive 2.indigoPlugin/Contents/Server Plugin/bmwcdapi.py", line 149, in get_vehicle_data
TypeError: 'NoneType' object has no attribute '__getitem__'
BMW Connected Drive Error plugin runConcurrentThread function returned or failed (will attempt again in 10 seconds)
Feb 26, 2020 at 7:47:33 PM
Reloading plugin "BMW Connected Drive 0.0.6"
Stopping plugin "BMW Connected Drive 0.0.6" (pid 68771)
BMW Connected Drive Debug runConcurrentThread ending
BMW Connected Drive BMW Account: Stopping cdAccount Device 372344672
BMW Connected Drive Ryan's BMW 540ix: Stopping cdVehicle Device 105421725
BMW Connected Drive Stopping Connected Drive
Stopped plugin "BMW Connected Drive 0.0.6"
Starting plugin "BMW Connected Drive 0.0.6" (pid 69506)
BMW Connected Drive Debug logLevel = 5
Started plugin "BMW Connected Drive 0.0.6"
BMW Connected Drive Starting Connected Drive
BMW Connected Drive Debug updateFrequency = 300.0
BMW Connected Drive BMW Account: Starting cdAccount Device
BMW Connected Drive Error get_tokens AUTH Error, exception = [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:590)
BMW Connected Drive Threaddebug BMW Account: getDeviceStateList, base state_list = States : (list)
Item : (dict)
Disabled : false (bool)
Key : authenticated (string)
StateLabel : Authenticated (yes or no) (string)
TriggerLabel : Authenticated (string)
Type : 52 (integer)
BMW Connected Drive Threaddebug BMW Account: getDeviceStateList, final state_list = States : (list)
Item : (dict)
Disabled : false (bool)
Key : authenticated (string)
StateLabel : Authenticated (yes or no) (string)
TriggerLabel : Authenticated (string)
Type : 52 (integer)
BMW Connected Drive Ryan's BMW 540ix: Starting cdVehicle Device
BMW Connected Drive Threaddebug Ryan's BMW 540ix: getDeviceStateList, base state_list = States : (list)
Item : (dict)
Disabled : false (bool)
Key : status (string)
StateLabel : UI Status (string)
TriggerLabel : UI Status (string)
Type : 150 (integer)
BMW Connected Drive Threaddebug Ryan's BMW 540ix: getDeviceStateList, final state_list = States : (list)
Item : (dict)
Disabled : false (bool)
Key : status (string)
StateLabel : UI Status (string)
TriggerLabel : UI Status (string)
Type : 150 (integer)
BMW Connected Drive Debug runConcurrentThread starting
BMW Connected Drive Error get_tokens AUTH Error, exception = [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:590)
BMW Connected Drive Debug ConnectedDrive account 372344672 not authenticated, skipping update
BMW Connected Drive Debug ConnectedDrive get_vehicle_data: WBAJE7C55KWD55588
BMW Connected Drive Error Error in plugin execution runConcurrentThread:
Traceback (most recent call last):
File "plugin.py", line 140, in runConcurrentThread
File "plugin.py", line 177, in updateVehicle
File "/Library/Application Support/Perceptive Automation/Indigo 7.4/Plugins/BMW ConnectedDrive.indigoPlugin/Contents/Server Plugin/bmwcdapi.py", line 149, in get_vehicle_data
TypeError: 'NoneType' object has no attribute '__getitem__'
BMW Connected Drive Error plugin runConcurrentThread function returned or failed (will attempt again in 10 seconds)
BMW Connected Drive Debug runConcurrentThread starting
ryanbuckner wrote:Sierra 10.12.6
It had been working fine up until today. I tested my credentials on the website and they passed.
BMW Connected Drive Error get_tokens AUTH Error, exception = [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:590)
BMW Connected Drive Debug ConnectedDrive get_vehicles
BMW Connected Drive Error Error in plugin execution GetUiDynamicList:
Traceback (most recent call last):
File "plugin.py", line 258, in get_vehicle_list
File "/Library/Application Support/Perceptive Automation/Indigo 7.4/Plugins/BMW ConnectedDrive.indigoPlugin/Contents/Server Plugin/bmwcdapi.py", line 145, in get_vehicles
TypeError: 'NoneType' object has no attribute '__getitem__'
# Imports
import string
import datetime
from math import radians, cos, sin, asin, sqrt
# Constants
home_lat = 50.1234567 # Your home latitude, get it from Google maps by clicking on your house
home_log = 0.1234567 # Your home longitude, get it from Google maps by clicking on your house
car_device_id = 123456789 # Device ID of the vehicle you created with the Connected Drive plugin
geo_distance_unit = "meters" # meters or miles
geo_fence_distance = 50 # How big you want the geofence to be for your car to be considered at home
wait_minutes_before_alert = 5 # How many minutes to wait before sending an alert
repeat_alerts = True # Set to false to not receive the same alert repeatedly every time the Connected Drive plugin refreshes the data
variables_folder_id = 987654321 # Folder ID where you want the variables that this script uses to be created
# Functions
def log(msg):
indigo.server.log(msg, type="Check Car is Locked")
def haversine_distance(lon1, lat1, lon2, lat2):
# convert decimal degrees to radians
lon1, lat1, lon2, lat2 = map(radians, [lon1, lat1, lon2, lat2])
# haversine formula
dlon = lon2 - lon1
dlat = lat2 - lat1
a = sin(dlat/2)**2 + cos(lat1) * cos(lat2) * sin(dlon/2)**2
c = 2 * asin(sqrt(a))
if geo_distance_unit == "meters":
r = 6371 # Radius of earth in kilometers
if geo_distance_unit == "miles":
r = 3956 # Radius of earth in miles
return round(c * r, 2)
# Main code
my_car = indigo.devices[car_device_id]
my_car_name = my_car.name
my_car_lat_pos = my_car.states["s_position_lat"]
my_car_lon_pos = my_car.states["s_position_lon"]
car_open = False
message_and = ""
alert_message = ""
varName = my_car_name.replace(" ", "_") + "_Alert_Active"
try:
alert_active_var = indigo.variables[varName]
except:
indigo.variable.create(varName, value="false", folder=variables_folder_id)
alert_active_var = indigo.variables[varName]
alert_active = alert_active_var.value
varName = my_car_name.replace(" ", "_") + "_Override_Alert"
try:
override_alert = indigo.variables[varName].value
except:
indigo.variable.create(varName, value="false", folder=variables_folder_id)
override_alert = indigo.variables[varName].value
# Calculate distance from homer to the current reported position of the car
distance_from_home = haversine_distance(home_lat, home_log, my_car_lat_pos, my_car_lon_pos)
# Make sure the distance is within the geofence
if distance_from_home <= geo_fence_distance:
car_Last_Updated_DT = datetime.datetime.strptime(my_car.states["s_updateTime"], "%Y-%m-%dT%H:%M:%S+0000")
car_Last_Updated_DT_str = car_Last_Updated_DT.strftime("%-d-%B-%Y %-H:%M.%S")
device_Last_Updated_DT = my_car.lastChanged
device_Last_Updated_DT_str = device_Last_Updated_DT.strftime("%-d-%B-%Y %-H:%M.%S")
car_minutes_diff = int(round((datetime.datetime.now() - car_Last_Updated_DT).total_seconds() / 60.0, 0))
device_minutes_diff = int(round((datetime.datetime.now() - device_Last_Updated_DT).total_seconds() / 60.0, 0))
# Only send alert after wating time is reached
if car_minutes_diff >= wait_minutes_before_alert:
log(my_car_name + " distance from home is: " + str(distance_from_home) + " " + geo_distance_unit)
log("Minutes since last car change: " + str(car_minutes_diff) + " (" + car_Last_Updated_DT_str + ")")
log("Minutes since last device update: " + str(device_minutes_diff) + " (" + device_Last_Updated_DT_str + ")")
car_feature_name = []
car_feature_state = []
# Fetch all the car features and their statuses
my_car_status = my_car.states["status"]
my_car_doors_lock_state = my_car.states["s_doorLockState"]
car_feature_name.append("Driver Front Door")
car_feature_name.append("Driver Rear Door")
car_feature_name.append("Passenger Front Door")
car_feature_name.append("Passenger Rear Door")
car_feature_name.append("Driver Front Window")
car_feature_name.append("Driver Rear Window")
car_feature_name.append("Passenger Front Window")
car_feature_name.append("Passenger Rear Window")
car_feature_name.append("Hood")
car_feature_name.append("Sunroof")
car_feature_name.append("Trunk")
car_feature_state.append(my_car.states["s_doorDriverFront"])
car_feature_state.append(my_car.states["s_doorDriverRear"])
car_feature_state.append(my_car.states["s_doorPassengerFront"])
car_feature_state.append(my_car.states["s_doorPassengerRear"])
car_feature_state.append(my_car.states["s_windowDriverFront"])
car_feature_state.append(my_car.states["s_windowDriverRear"])
car_feature_state.append(my_car.states["s_windowPassengerFront"])
car_feature_state.append(my_car.states["s_windowPassengerRear"])
car_feature_state.append(my_car.states["s_hood"])
car_feature_state.append(my_car.states["s_sunroof"])
car_feature_state.append(my_car.states["s_trunk"])
# Loop through list to check any features not Closed
for idx, state in enumerate(car_feature_state):
if state not in "CLOSED":
car_open = True
log(car_feature_name[idx] + " is " + state.title())
alert_message = alert_message + message_and + car_feature_name[idx] + " is " + state.title()
message_and = " and "
# Make sure care is not just LOCKED but also SECURED (alarm on)
if my_car_status not in "SECURED" or my_car_doors_lock_state not in "SECURED":
car_open = True
log("Car status: " + my_car_status.title() + " / Doors Lock State: " + my_car_doors_lock_state.title())
if alert_message:
log(alert_message)
# The conditions for the alert are: car is not secured and either first time alert or we want repeated alerts and no override
if car_open and (alert_active == "false" or repeat_alerts) and override_alert == "false":
msg_body = "Car is at home (distance " + str(distance_from_home) + " " + geo_distance_unit + "). Car status: " + my_car_status.title() + " / Doors Lock State: " + my_car_doors_lock_state.title()
if alert_message:
msg_body = msg_body + ". " + alert_message + "."
PushoverPlugin = indigo.server.getPlugin('io.thechad.indigoplugin.pushover')
if PushoverPlugin.isEnabled():
PushoverAlertProps = {'msgTitle' : my_car_name + " alert",
'msgBody' : msg_body,
'msgSound' :'pushover',
'msgPriority' :'1',
'msgDevice' :'',
'msgSupLinkUrl' :'',
'msgSupLinkTitle':''
}
PushoverPlugin.executeAction("send", props=PushoverAlertProps)
else:
indigo.server.log('Error: Pushover plugin is not available!')
alert_active = "true"
else:
# Car is at home but secured so reset any active alerts
alert_active = "false"
else:
# Car no longer at home so reset any active alerts
alert_active = "false"
# Save back value to variable
indigo.variable.updateValue(alert_active_var, alert_active)
Users browsing this forum: No registered users and 4 guests