Conversation
| # Set stdout as logging handler | ||
| root_log = logging.getLogger() | ||
| root_log.setLevel(logging.DEBUG) | ||
| handler = logging.StreamHandler(sys.stdout) |
There was a problem hiding this comment.
Not necessarily required, but since SenseLink uses logging you'll need this to see output on stdout
| # Python3 -m pip install senselink | ||
| from senselink import SenseLink | ||
|
|
There was a problem hiding this comment.
Uses the new 2.x version PyPI package
| if not tesla.authorized: | ||
| tesla.refresh_token(refresh_token=input('Enter SSO refresh token: ')) |
There was a problem hiding this comment.
I use a refresh token to login to Tesla, remove these lines to go back to the original auth method
| # Set 0 watts to plug | ||
| mutable_plug.data_source.power = 0 |
There was a problem hiding this comment.
I picked a few spots where it seemed like you'd want to set the plug power to zero, but correct me if I'm wrong!
| # Set plug power to new power? | ||
| # mutable_plug.data_source.power = ... |
There was a problem hiding this comment.
Somewhere in these if/else blocks you'd want to provide the "new" power reading to the plug. Alternatively, it may be smarter to simply do it at the end once it's been decided what to do (i.e. something like a new_power variable that you can use at the end).
| chargedata['charge_amps'], "of a possible", | ||
| chargedata['charge_current_request_max'], "Amps,", | ||
| chargedata['charger_voltage'], "Volts, ", | ||
| chargedata['fast_charger_type'], |
There was a problem hiding this comment.
None of this "removed" section was intentionally changed, fyi
|
|
||
| async def main(): | ||
| # Get config | ||
| config = open('config.yml', 'r') |
There was a problem hiding this comment.
Assumes config file is in the same directory
As mentioned on the Sense forum, here's a pull request that merges in SenseLink with everything working as far as I can tell.
The remaining work would be to make sure that the appropriate value is set to mutable_plug.data_source.power at the appropriate spots. You'll know better where to further add it in your code, but I think you'd want to set it to the latest power value whenever TesSense changes the charger power/current - including when charging stops.
I'll make a few comments on the code itself as well.