Skip to content

Integrated SenseLink#2

Open
cbpowell wants to merge 2 commits intoisrandy:mainfrom
cbpowell:main
Open

Integrated SenseLink#2
cbpowell wants to merge 2 commits intoisrandy:mainfrom
cbpowell:main

Conversation

@cbpowell
Copy link

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.

Comment on lines +22 to +25
# Set stdout as logging handler
root_log = logging.getLogger()
root_log.setLevel(logging.DEBUG)
handler = logging.StreamHandler(sys.stdout)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessarily required, but since SenseLink uses logging you'll need this to see output on stdout

Comment on lines +40 to +42
# Python3 -m pip install senselink
from senselink import SenseLink

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uses the new 2.x version PyPI package

Comment on lines +54 to +55
if not tesla.authorized:
tesla.refresh_token(refresh_token=input('Enter SSO refresh token: '))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use a refresh token to login to Tesla, remove these lines to go back to the original auth method

Comment on lines +92 to +93
# Set 0 watts to plug
mutable_plug.data_source.power = 0
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

Comment on lines +142 to +143
# Set plug power to new power?
# mutable_plug.data_source.power = ...
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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'],
Copy link
Author

@cbpowell cbpowell Mar 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None of this "removed" section was intentionally changed, fyi


async def main():
# Get config
config = open('config.yml', 'r')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assumes config file is in the same directory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant