ERROR: column "s_singleimmediatecharging" cannot be cast au

Posted on
Mon Dec 23, 2019 2:02 pm
FlyingDiver offline
User avatar
Posts: 7213
Joined: Jun 07, 2014
Location: Southwest Florida, USA

ERROR: column "s_singleimmediatecharging" cannot be cast au

Full errors:
Code: Select all
 SQL Logger Error                exception trying to update table device_history_1294232459 ("Joe's X4 M40i") -- unable to modify table
   SQL Logger Error                ERROR:  column "s_singleimmediatecharging" cannot be cast automatically to type boolean

   SQL Logger Error                exception trying to insert row into table device_history_1294232459 ("Joe's X4 M40i") -- unable to modify table
   SQL Logger Error                ERROR:  column "status_ui" of relation "device_history_1294232459" does not exist at character 367

   SQL Logger Error                INSERT INTO device_history_1294232459 ("v_dealer_postalcode", "v_color", "s_remainingrangefuel", "v_a4a", "v_drivetrain", "s_position_heading", "s_updatereason", "v_hornblow", "v_remote360", "s_vehiclecountry", "v_brand", "v_ipa", "s_mileage", "v_lastdestinations", "v_climatecontrolres", "v_intermodalrouting", "s_doorpassengerfront", "v_chargenow", "v_colorcode", "status_ui", "v_sendpoi", "s_hood", "v_dealer_street", "s_windowdriverrear", "s_remainingfuel", "v_rangemap", "s_windowdriverfront", "v_dealer_country", "s_rearwindow", "v_lightflash", "v_vehiclefinderrestriction", "s_sunroof", "v_climatecontrol", "v_climatefunction", "v_carcloud", "status", "v_doorlock", "v_remotesoftwareupgrade", "v_onlinesearchmode", "v_hasalarmsystem", "v_chargingcontrol", "s_position_lat", "v_fueltype", "s_fuelpercent", "s_doorlockstate", "v_bodytype", "v_vehiclefinder", "s_position_status", "v_hmiversion", "s_windowpassengerfront", "v_climatenow", "v_hub", "v_dealer_name", "s_positionlight", "v_doorunlock", "v_dealer_city", "s_remainingrangefuelmls", "v_climatenowres", "v_dealer_phone", "s_doordriverrear", "s_doordriverfront", "s_doorpassengerrear", "s_parkinglight", "s_internaldatatimeutc", "v_smartsolution", "s_position_lon", "v_lsctype", "v_steering", "s_windowpassengerrear", "s_updatetime", "v_countrycode", "v_model", "v_yearofconstruction", "s_trunk") VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s);


Note that this plugin uses getDeviceStateList() to define the states, not Devices.xml. That code is as follows:

Code: Select all
    def getDeviceStateList(self, device):
        state_list = indigo.PluginBase.getDeviceStateList(self, device)
        if device.id in self.cd_vehicles and self.cd_vehicles[device.id]:
           
            for item in self.cd_vehicles[device.id]:
                key = item['key']
                value = item['value']
                if isinstance(value, (float, int)):
                    dynamic_state = self.getDeviceStateDictForNumberType(unicode(key), unicode(key), unicode(key))
                elif isinstance(value, (str, unicode)):
                    dynamic_state = self.getDeviceStateDictForStringType(unicode(key), unicode(key), unicode(key))
                elif isinstance(value, bool):
                    dynamic_state = self.getDeviceStateDictForBoolTrueFalseType(unicode(key), unicode(key), unicode(key))
                else:
                    self.logger.debug(u"{}: getDeviceStateList, unknown type for key = {}".format(dev.name, key))
                    continue
                state_list.append(dynamic_state)
        return state_list


Here's the complete sequence when I add a device.

Code: Select all
 SQL Logger                      adding column "s_doordriverfront" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "s_doordriverrear" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "s_doorlockstate" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "s_doorpassengerfront" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "s_doorpassengerrear" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "s_fuelpercent" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "s_hood" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "s_internaldatatimeutc" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "s_mileage" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "s_parkinglight" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "s_positionlight" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "s_position_heading" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "s_position_lat" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "s_position_lon" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "s_position_status" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "s_rearwindow" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "s_remainingfuel" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "s_remainingrangefuel" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "s_remainingrangefuelmls" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "s_singleimmediatecharging" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "s_sunroof" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "s_trunk" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "s_updatereason" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "s_updatetime" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "s_vehiclecountry" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "s_windowdriverfront" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "s_windowdriverrear" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "s_windowpassengerfront" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "s_windowpassengerrear" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "v_a4a" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "v_bodytype" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "v_brand" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "v_carcloud" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "v_chargenow" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "v_chargingcontrol" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "v_climatecontrol" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "v_climatecontrolres" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "v_climatefunction" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "v_climatenow" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "v_climatenowres" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "v_color" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "v_colorcode" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "v_countrycode" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "v_dealer_city" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "v_dealer_country" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "v_dealer_name" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "v_dealer_phone" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "v_dealer_postalcode" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "v_dealer_street" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "v_doorlock" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "v_doorunlock" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "v_drivetrain" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "v_fueltype" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "v_hasalarmsystem" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "v_hmiversion" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "v_hornblow" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "v_hub" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "v_intermodalrouting" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "v_ipa" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "v_lastdestinations" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "v_lightflash" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "v_lsctype" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "v_model" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "v_onlinesearchmode" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "v_rangemap" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "v_remote360" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "v_remotesoftwareupgrade" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "v_sendpoi" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "v_smartsolution" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "v_statisticsavailable" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "v_statisticscommunityenabled" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "v_steering" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "v_vehiclefinder" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "v_vehiclefinderrestriction" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      adding column "v_yearofconstruction" to table device_history_1294232459 ("Joe's X4 M40i")
   SQL Logger                      modifying column "s_fuelpercent" type of table device_history_1294232459 ("Joe's X4 M40i") from integer to REAL
   SQL Logger                      modifying column "s_position_lat" type of table device_history_1294232459 ("Joe's X4 M40i") from integer to REAL
   SQL Logger                      modifying column "s_position_lon" type of table device_history_1294232459 ("Joe's X4 M40i") from integer to REAL
   SQL Logger                      modifying column "s_singleimmediatecharging" type of table device_history_1294232459 ("Joe's X4 M40i") from integer to BOOL
   SQL Logger Error                exception trying to update table device_history_1294232459 ("Joe's X4 M40i") -- unable to modify table
   SQL Logger Error                ERROR:  column "s_singleimmediatecharging" cannot be cast automatically to type boolean

   SQL Logger Error                exception trying to insert row into table device_history_1294232459 ("Joe's X4 M40i") -- unable to modify table
   SQL Logger Error                ERROR:  column "status_ui" of relation "device_history_1294232459" does not exist at character 367

   SQL Logger Error                INSERT INTO device_history_1294232459 ("v_dealer_postalcode", "v_color", "s_remainingrangefuel", "v_a4a", "v_drivetrain", "s_position_heading", "s_updatereason", "v_hornblow", "v_remote360", "s_vehiclecountry", "v_brand", "v_ipa", "s_mileage", "v_lastdestinations", "v_climatecontrolres", "v_intermodalrouting", "s_doorpassengerfront", "v_chargenow", "v_colorcode", "status_ui", "v_sendpoi", "s_hood", "v_dealer_street", "s_windowdriverrear", "s_remainingfuel", "v_rangemap", "s_windowdriverfront", "v_dealer_country", "s_rearwindow", "v_lightflash", "v_vehiclefinderrestriction", "s_sunroof", "v_climatecontrol", "v_climatefunction", "v_carcloud", "status", "v_doorlock", "v_remotesoftwareupgrade", "v_onlinesearchmode", "v_hasalarmsystem", "v_chargingcontrol", "s_position_lat", "v_fueltype", "s_fuelpercent", "s_doorlockstate", "v_bodytype", "v_vehiclefinder", "s_position_status", "v_hmiversion", "s_windowpassengerfront", "v_climatenow", "v_hub", "v_dealer_name", "s_positionlight", "v_doorunlock", "v_dealer_city", "s_remainingrangefuelmls", "v_climatenowres", "v_dealer_phone", "s_doordriverrear", "s_doordriverfront", "s_doorpassengerrear", "s_parkinglight", "s_internaldatatimeutc", "v_smartsolution", "s_position_lon", "v_lsctype", "v_steering", "s_windowpassengerrear", "s_updatetime", "v_countrycode", "v_model", "v_yearofconstruction", "s_trunk") VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s);

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Mon Dec 23, 2019 3:48 pm
matt (support) offline
Site Admin
User avatar
Posts: 21416
Joined: Jan 27, 2003
Location: Texas

Re: ERROR: column "s_singleimmediatecharging" cannot be cas

I think when Indigo first adds the column here:

SQL Logger adding column "s_singleimmediatecharging" to table device_history_1294232459 ("Joe's X4 M40i")

the device state type (as defined by the plugin's getDeviceStateList() method) is an integer, but then the actual current state value for s_singleimmediatecharging is a boolean. The SQL Logger plugin tries to change that column type from an integer to a boolean, but that fails; I think because there is already a row in the table that has s_singleimmediatecharging with an integer value so Postgres balks at the request because the data in the table (integer I think?) cannot be converted to the new column type (boolean).

Image

Posted on
Mon Dec 23, 2019 4:06 pm
FlyingDiver offline
User avatar
Posts: 7213
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: ERROR: column "s_singleimmediatecharging" cannot be cas

Python bug, I think.

Code: Select all
Python 2.7.16 (default, Nov  9 2019, 05:55:08)
[GCC 4.2.1 Compatible Apple LLVM 11.0.0 (clang-1100.0.32.4) (-macos10.15-objc-s on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> foo = False
>>> print isinstance(foo, bool)
True
>>> print isinstance(foo, int)
True
>>>


Or I guess all bools are also ints? But not all ints are bools.

Code: Select all
>>> foo = 1
>>> print isinstance(foo, int)
True
>>> print isinstance(foo, bool)
False
>>>


I reordered that code to test for bools first. ;)

Or I could have changed it to type(foo) instead, I think. Doing a little research shows that bools are a subclass of int, so the isinstance() call isn't really a bug. Just an unexpected side effect.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 3 guests