However, I have a problem where for my Powerwall, getBridge(); is returning null - so the TeslaAccountHandler isn’t recognising that my powerwall is listed in my account.
Wondering if anyone has any idea what I’m doing wrong? Note this is VERY much still WIP… the powerwall ‘thing’ doesn’t do anything yet…
From a quick skim of the code nothing looks obviously wrong.
I assume that you are manually adding your Powerwall things as you do not seem to have touched the DiscoveryService(s).
Are you sure you have been actually linking your Powerwall things to an Account when you have been creating them? It’s easy to miss if you are quickly clicking through and the Paper UI will let you create them without a bridge even if your ThingHandler cannot work without one.
Thanks for the review… Yes I definitely have a bridge listed - you’re right - I’m currently manually creating the item, but I had selected the bridge, and the bridge is online.
Well that would be too easy of a solution I guess. Something weird is going on.
I just downloaded and built your fork and it worked fine for me. The call to getBridge() inside TeslaPowerwallHandler#initialize() does not return null.
Maybe try clearing the openHAB cache in case some remnants of an old version of the addon are messing things up?
2020-04-13 10:20:12.167 [DEBUG] [ternal.handler.TeslaPowerwallHandler] - Initializing the Tesla Powerwall handler for tesla:powerwall2:87784f5c
2020-04-13 10:20:12.169 [DEBUG] [ternal.handler.TeslaPowerwallHandler] - We don't do anything yet but we got here!
2020-04-13 10:20:12.171 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.initialize()' on 'org.openhab.binding.tesla.internal.handler.TeslaPowerwallHandler@e7e6df': null
java.lang.NullPointerException: null
at org.openhab.binding.tesla.internal.handler.TeslaPowerwallHandler.initialize(TeslaPowerwallHandler.java:126) ~[?:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_222]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_222]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_222]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_222]
at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:152) [bundleFile:?]
at org.eclipse.smarthome.core.internal.common.Invocation.call(Invocation.java:52) [bundleFile:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_222]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_222]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_222]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_222]
2020-04-13 10:20:12.244 [ERROR] [core.thing.internal.ThingManagerImpl] - Exception occurred while initializing handler of thing 'tesla:powerwall2:87784f5c': null
java.lang.NullPointerException: null
at org.openhab.binding.tesla.internal.handler.TeslaPowerwallHandler.initialize(TeslaPowerwallHandler.java:126) ~[?:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_222]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_222]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_222]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_222]
at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:152) [bundleFile:?]
at org.eclipse.smarthome.core.internal.common.Invocation.call(Invocation.java:52) [bundleFile:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_222]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_222]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_222]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_222]
2020-04-13 10:20:12.372 [DEBUG] [internal.handler.TeslaAccountHandler] - Setting up an authenticated connection to the Tesla back-end
2020-04-13 10:20:12.603 [INFO ] [b.core.service.AbstractActiveService] - HTTP Refresh Service has been started
2020-04-13 10:20:14.502 [DEBUG] [internal.handler.TeslaAccountHandler] - Authenticating: Response: 200:OK
2020-04-13 10:20:15.009 [WARN ] [rwall.internal.TeslaPowerwallHandler] - This binding is read only
2020-04-13 10:20:15.011 [WARN ] [rwall.internal.TeslaPowerwallHandler] - This binding is read only
2020-04-13 10:20:15.011 [WARN ] [rwall.internal.TeslaPowerwallHandler] - This binding is read only
2020-04-13 10:20:15.012 [WARN ] [rwall.internal.TeslaPowerwallHandler] - This binding is read only
2020-04-13 10:20:15.013 [WARN ] [rwall.internal.TeslaPowerwallHandler] - This binding is read only
2020-04-13 10:20:15.011 [WARN ] [rwall.internal.TeslaPowerwallHandler] - This binding is read only
2020-04-13 10:20:15.010 [WARN ] [rwall.internal.TeslaPowerwallHandler] - This binding is read only
2020-04-13 10:20:15.014 [WARN ] [rwall.internal.TeslaPowerwallHandler] - This binding is read only
2020-04-13 10:20:15.459 [DEBUG] [internal.handler.TeslaAccountHandler] - Querying the products: Response: 200:OK
2020-04-13 10:20:15.664 [DEBUG] [internal.handler.TeslaAccountHandler] - Querying the products: Response: 200:OK
2020-04-13 10:20:15.668 [DEBUG] [internal.handler.TeslaAccountHandler] - Powerwall is id STE20190628-00046/site_name Home Energy Gateway
2020-04-13 10:20:15.669 [DEBUG] [internal.handler.TeslaAccountHandler] - PS here
2020-04-13 10:20:15.670 [DEBUG] [internal.handler.TeslaAccountHandler] - PS here2
2020-04-13 10:20:15.672 [DEBUG] [internal.handler.TeslaAccountHandler] - PS here2a, bridge null
I’m afraid I don’t have anything Tesla so I cannot do any in depth debugging as I do not have a real account. I didn’t need one just to check that TeslaPowerwallHandler was getting its bridge.
It turns out that is not your problem though. I didn’t realise you were talking about calling getBridge() inside TeslaAccountHandler.
Looking inside connectRunnable I’m not sure how getBridge() can ever return non-null because I don’t think TeslaAccountHandler can have a bridge. I would be expecting it to call getThing() as it is the bridge itself.
Either something is going on in that binding I don’t understand or there was a mistake when refactoring some code. It looks like in the original binding the bridge is only used there to print some log messages, if it is a bug it could have easily slipped through as nothing else would have been broken.
If you have a Tesla car can you confirm if you ever see one of those "Found the vehicle with VIN '{}' in the list of vehicles you own"
log messages?
You might want to talk to @Kai as he seems to be the last one to have touched that bit of code.
Thanks Ross - appreciate your input anyway. I have no Tesla car - both our cars are conventional combustion engined vehicled
As I understand how the binding works - there is an ‘Account’ thing that does the work of actually talking to the Tesla API. The actual ‘thing’ (in my case the ‘Powerwall’) communicates via the ‘Account’ thing. In this context, the ‘Account’ thing is the bridge…
Yes, but when you call getBridge() inside TeslaAccountHandler near your “PS here” etc. logs you are asking for the bridge of the TeslaAccountHandler i.e.:
Thanks @rossgb
I don’t understand why - but your suggested change works.
I now get:
2020-04-13 19:17:58.796 [DEBUG] [ternal.handler.TeslaPowerwallHandler] - Disposing the Tesla handler for tesla:powerwall2:87784f5c
2020-04-13 19:17:59.370 [DEBUG] [internal.handler.TeslaAccountHandler] - Setting up an authenticated connection to the Tesla back-end
2020-04-13 19:17:59.440 [DEBUG] [ternal.handler.TeslaPowerwallHandler] - Initializing the Tesla Powerwall handler for tesla:powerwall2:87784f5c
2020-04-13 19:17:59.446 [DEBUG] [ternal.handler.TeslaPowerwallHandler] - We don't do anything yet but we got here!
2020-04-13 19:17:59.448 [DEBUG] [ternal.handler.TeslaPowerwallHandler] - Initializing the Tesla Powerwall handler - account = org.openhab.binding.tesla.internal.handler.TeslaAccountHandler@120e049
2020-04-13 19:18:00.426 [DEBUG] [internal.handler.TeslaAccountHandler] - Authenticating: Response: 200:OK
2020-04-13 19:18:01.227 [DEBUG] [internal.handler.TeslaAccountHandler] - Querying the products: Response: 200:OK
2020-04-13 19:18:01.423 [DEBUG] [internal.handler.TeslaAccountHandler] - Querying the products: Response: 200:OK
2020-04-13 19:18:01.427 [DEBUG] [internal.handler.TeslaAccountHandler] - Powerwall is id STE20190628-00046/site_name Home Energy Gateway
2020-04-13 19:18:01.428 [DEBUG] [internal.handler.TeslaAccountHandler] - Found the powerwall with battery_id 'STE20190628-00046' in the list of powerwalls you own
Now to continue work to make it actually do something useful That may need to wait til next weekend.
N.B. It’s because the Thing that TeslaAccountHandler is handling is the Tesla Account (bridge).
When you call TeslaAccountHandler#getBridge() you would be looking for another level of bridge (a non-existent bridge that is the parent to multiple Tesla Accounts)