openhab / openhab-addons

Add-ons for openHAB
https://www.openhab.org/
Eclipse Public License 2.0
1.88k stars 3.59k forks source link

Tesla Binding Java exception in logs for Seat heater #3261

Closed Rathna-K closed 6 years ago

Rathna-K commented 6 years ago

Hi there, in the openhab logs (/var/log/openhab2/openhab.log) for tesla binding there is a exception that keeps popping for Tesla Binding.

An exception occurred while parsing data received from the vehicle: 'java.lang.IllegalStateException: Expected an int but was BOOLEAN at line 1 column 315 path $.seat_heater_left'

not sure what this means but hopefully can be fixed!

kaikreuzer commented 6 years ago

@kgoderis Could you have a look?

kgoderis commented 6 years ago

@kaikreuzer @Rathna-K Sure. That is due to Tesla changing the API once again.

kgoderis commented 6 years ago

@Rathna-K Can you post more detailed logs please, with the Tesla binding set to TRACE. I can not reproduce the error. My logs look like

Request : climate_state:null:JerseyWebTarget { https://owner-api.teslamotors.com/api/1/vehicles/{vid}/data_request/{cmd} } yields {"inside_temp":null,"outside_temp":null,"driver_temp_setting":22.0,"passenger_temp_setting":22.0,"left_temp_direction":null,"right_temp_direction":null,"is_front_defroster_on":false,"is_rear_defroster_on":false,"fan_status":0,"is_climate_on":false,"min_avail_temp":15.0,"max_avail_temp":28.0,"**seat_heater_left":1,"seat_heater_right":0,"seat_heater_rear_left":0,"seat_heater_rear_right":0,"seat_heater_rear_center":0,"seat_heater_rear_right_back":0,"seat_heater_rear_left_back":0**,"battery_heater":false,"battery_heater_no_power":null,"is_preconditioning":false,"smart_preconditioning":false,"is_auto_conditioning_on":null,"timestamp":1519226277018}

with the seat_heaters returning int values, that consequently get converted to OnOffTypes afterwards. The only thing I can think of right now is that the value returned by Tesla is not 1 or 0, but 0, 1,2,3 indicating the actual level of the seat heater. Could be a coincidence, but my current setting of my seat heater is level "1".....

For completeness, what firmware version is your Tesla running? Mine is not the most recent one, it is one of the last releases of 2017

kgoderis commented 6 years ago

@Rathna-K Did a quick check, and indeed, it seems that API returns the absolute level of the seat heater, and not a pure boolean value. I will prepare a fix for this

Rathna-K commented 6 years ago

@kgoderis Thank you. I also noticed something but not sure if its truly an issue or it is at my end. The binding is setup and working fine. But when I set the temperature or turn Auto conditioning on in my mobile app, it doesnt reflect the same in OH. is this intended behavior? if not how do I go about debugging that? And another weird thing is when OH is started, the Auto Conditioning Switch is greyed out in Paper UI but not in Basic. once I turn it on in Basic, it gets enabled in Paper UI.

Rathna-K commented 6 years ago

@kgoderis Hey could you please take a look at the above questions? are you not having the issue of disabled Auto Conditioning button?

kgoderis commented 6 years ago

@Rathna-K I can not comment on the paperUI bit as I do not use it (too slow for the # of Things I have), but the Auto Condition switch and temperature channels are working correctly. Note that these are only updated once a minute. Also, the Tesla back-end sometimes returns "null" for the autoconditioning state, and therefore the state of the linked Item can be set to UNDEF, and thus the button in the UI might not be reflecting the real state

rvorsten commented 6 years ago

@kgoderis Karel, thanks for fixing this. Could you tell me in which jar version this fix 3261 is included? I have just installed Tesla binding 2.3.0.201802261314 (I also see this listed in karaf), which seems to be the correct one, but I still see the same error in my logging. Is this the correct versions indeed?

Minor difference: the error now appears in column 317, rather than 315 as per @Rathna-K comment above:

An exception occurred while parsing data received from the vehicle: 'java.lang.IllegalStateException: Expected an int but was BOOLEAN at line 1 column 317 path $.seat_heater_left'

I just updated my car's firmware last night. It's on 2018.6.1 641efac.

msvinth commented 6 years ago

I am still seeing this issue. I have built the binding to make sure I had the committed changes included. I have a Model X and is on update 2018.6.1 641efac. I added a log statement just before parsing the climate state:

case TESLA_CLIMATE_STATE: { logger.info("CLIMATE_STATE {}", result); climateState = gson.fromJson(result, ClimateState.class); break;

and this is what I got back. Some of seat heater are returning booleans and not integers. Strange...

2018-03-04 14:54:51.417 [INFO ] [b.binding.tesla.handler.TeslaHandler] - CLIMATE_STATE {"inside_temp":7.6,"outside_temp":-2.0,"driver_temp_setting":21.5,"passenger_temp_setting":21.5,"left_temp_direction":433,"right_temp_direction":433,"is_front_defroster_on":false,"is_rear_defroster_on":false,"fan_status":0,"is_climate_on":false,"min_avail_temp":15.0,"max_avail_temp":28.0,"seat_heater_left":false,"seat_heater_right":false,"seat_heater_rear_left":false,"seat_heater_rear_right":false,"seat_heater_rear_center":false,"seat_heater_rear_right_back":0,"seat_heater_rear_left_back":0,"battery_heater":false,"battery_heater_no_power":false,"steering_wheel_heater":false,"wiper_blade_heater":false,"side_mirror_heaters":false,"is_preconditioning":false,"smart_preconditioning":false,"is_auto_conditioning_on":false,"timestamp":1520171691214} 2018-03-04 14:54:51.426 [ERROR] [b.binding.tesla.handler.TeslaHandler] - An exception occurred while parsing data received from the vehicle: 'java.lang.IllegalStateException: Expected an int but was BOOLEAN at line 1 column 314 path $.seat_heater_left'

kgoderis commented 6 years ago

@msvinth Ok let me check that. I was pushed the same firmware version a few days ago @Rathna-K Are you on the same firmware version as us, and/or can you confirm that those heater fields switched back from integers to booleans ?

What could be happening is that Tesla is sending both boolean and integer values for those variables. It will require some more testing from my end to pinpoint what they are exactly doing

Rathna-K commented 6 years ago

I am also still getting the error and I am on the latest firmware. also a model x.

2018-03-05 10:34:33.325 [INFO ] [core.karaf.internal.FeatureInstaller] - Uninstalled 'openhab-misc-openhabcloud'
2018-03-05 10:34:46.221 [INFO ] [core.karaf.internal.FeatureInstaller] - Uninstalled 'openhab-misc-ruleengine'
2018-03-05 10:35:20.606 [ERROR] [b.binding.tesla.handler.TeslaHandler] - An exception occurred while parsing data received from the vehicle: 'java.lang.IllegalStateException: Expected an int but was BOOLEAN at line 1 column 314 path $.seat_heater_left'
2018-03-05 10:36:25.924 [ERROR] [b.binding.tesla.handler.TeslaHandler] - An exception occurred while parsing data received from the vehicle: 'java.lang.IllegalStateException: Expected an int but was BOOLEAN at line 1 column 314 path $.seat_heater_left'
2018-03-05 10:37:23.924 [ERROR] [b.binding.tesla.handler.TeslaHandler] - An exception occurred while parsing data received from the vehicle: 'java.lang.IllegalStateException: Expected an int but was BOOLEAN at line 1 column 314 path $.seat_heater_left'
2018-03-05 10:37:44.644 [ERROR] [b.binding.tesla.handler.TeslaHandler] - Event Stream : An exception occurred while reading events : 'Read timed out'
2018-03-05 10:38:21.991 [ERROR] [b.binding.tesla.handler.TeslaHandler] - An exception occurred while parsing data received from the vehicle: 'java.lang.IllegalStateException: Expected an int but was BOOLEAN at line 1 column 314 path $.seat_heater_left'
2018-03-05 10:39:21.486 [ERROR] [b.binding.tesla.handler.TeslaHandler] - An exception occurred while parsing data received from the vehicle: 'java.lang.IllegalStateException: Expected an int but was BOOLEAN at line 1 column 314 path $.seat_heater_left'
2018-03-05 10:40:21.605 [ERROR] [b.binding.tesla.handler.TeslaHandler] - An exception occurred while parsing data received from the vehicle: 'java.lang.IllegalStateException: Expected an int but was BOOLEAN at line 1 column 314 path $.seat_heater_left'
2018-03-05 10:41:21.703 [ERROR] [b.binding.tesla.handler.TeslaHandler] - An exception occurred while parsing data received from the vehicle: 'java.lang.IllegalStateException: Expected an int but was BOOLEAN at line 1 column 314 path $.seat_heater_left'
2018-03-05 10:42:21.871 [ERROR] [b.binding.tesla.handler.TeslaHandler] - An exception occurred while parsing data received from the vehicle: 'java.lang.IllegalStateException: Expected an int but was BOOLEAN at line 1 column 314 path $.seat_heater_left'
2018-03-05 10:43:21.756 [ERROR] [b.binding.tesla.handler.TeslaHandler] - An exception occurred while parsing data received from the vehicle: 'java.lang.IllegalStateException: Expected an int but was BOOLEAN at line 1 column 314 path $.seat_heater_left'
2018-03-05 10:44:22.228 [ERROR] [b.binding.tesla.handler.TeslaHandler] - An exception occurred while parsing data received from the vehicle: 'java.lang.IllegalStateException: Expected an int but was BOOLEAN at line 1 column 314 path $.seat_heater_left'
2018-03-05 10:45:24.235 [ERROR] [b.binding.tesla.handler.TeslaHandler] - An exception occurred while parsing data received from the vehicle: 'java.lang.IllegalStateException: Expected an int but was BOOLEAN at line 1 column 314 path $.seat_heater_left'
2018-03-05 10:46:16.242 [ERROR] [b.binding.tesla.handler.TeslaHandler] - Event Stream : An exception occurred while reading events : 'Read timed out'
2018-03-05 10:46:21.498 [ERROR] [b.binding.tesla.handler.TeslaHandler] - An exception occurred while parsing data received from the vehicle: 'java.lang.IllegalStateException: Expected an int but was BOOLEAN at line 1 column 314 path $.seat_heater_left'
2018-03-05 10:47:21.704 [ERROR] [b.binding.tesla.handler.TeslaHandler] - An exception occurred while parsing data received from the vehicle: 'java.lang.IllegalStateException: Expected an int but was BOOLEAN at line 1 column 314 path $.seat_heater_left

Admin edit: please use tripple `

rvorsten commented 6 years ago

This is probably the stupidest question ever, but I can no longer locate where I downloaded the 2.3.0 snapshot version of the Tesla binding (.jar) from. Can someone post a link please?

Many thanks, Ronald

martinvw commented 6 years ago

You can use this one:

https://openhab.jfrog.io/openhab/libs-snapshot-local/org/openhab/binding/org.openhab.binding.tesla/2.3.0-SNAPSHOT/org.openhab.binding.tesla-2.3.0-20180423.075323-78.jar

phuongpham commented 5 years ago

UPDATED Hi Just got my openHAB upgraded from 1.8.3 to 2.4.0 When I install the tesla binding (2.4) thru Paper UI. I get the similar error as describe in this thread: 2018-12-24 11:02:53.550 [ERROR] [b.binding.tesla.handler.TeslaHandler] - An exception occurred while parsing data received from the vehicle: 'java.lang.IllegalStateException: Expected a boolean but was NUMBER at line 1 column 460 path $.seat_heater_left'

I have tried to use different snapshot but still get the same problem: org.openhab.binding.tesla-2.4.0-20181214.175431-120.jar
org.openhab.binding.tesla-2.5.0-20181220.212413-3.jar

For me it seems like the API is going back to boolean instead of number?

The tesla currently running on 2018.48.12.1 d6999f5