Skip to content

Commit

Permalink
Improved tesla_proxy config detection
Browse files Browse the repository at this point in the history
  • Loading branch information
sftman18 committed Aug 29, 2024
1 parent 84261b0 commit be8d13e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
17 changes: 8 additions & 9 deletions PVCharge.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,20 @@
else:
logging.warning("Unknown logging level")

# Test if we have parameters for TeslaBleHttpProxy
if "ENABLE_TESLA_PROXY" in config:
tesla_proxy_config_exists = config["ENABLE_TESLA_PROXY"]
else:
tesla_proxy_config_exists = "False"

# Initialize classes
Energy = routines.PowerUsage()
if tesla_proxy_config_exists == "True":
logging.debug("Using TeslaProxy")
Car = routines.TeslaProxy()
Messages = routines.MqttCallbacks()
if "ENABLE_TESLA_PROXY" in config:
if config["ENABLE_TESLA_PROXY"] == "True":
logging.debug("Using TeslaProxy")
Car = routines.TeslaProxy()
else:
logging.debug("Using TeslaCommands")
Car = routines.TeslaCommands()
else:
logging.debug("Using TeslaCommands")
Car = routines.TeslaCommands()
Messages = routines.MqttCallbacks()

# Control loop variables
car_is_charging = False
Expand Down
12 changes: 5 additions & 7 deletions routines.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@
with open("config.toml", mode="rb") as fp:
config = tomllib.load(fp)

# Test if we have parameters for TeslaBleHttpProxy
if "ENABLE_TESLA_PROXY" in config:
tesla_proxy_config_exists = config["ENABLE_TESLA_PROXY"]
else:
tesla_proxy_config_exists = "False"

class PowerUsage:
"""Class to request data from the eGauge web API"""
Expand Down Expand Up @@ -301,8 +296,11 @@ def __init__(self):
self.var_topic_teslamate_charge_limit_soc = 0
self.var_topic_teslamate_state = False

if tesla_proxy_config_exists == "True":
self.car_cmd = TeslaProxy()
if "ENABLE_TESLA_PROXY" in config:
if config["ENABLE_TESLA_PROXY"] == "True":
self.car_cmd = TeslaProxy()
else:
self.car_cmd = TeslaCommands()
else:
self.car_cmd = TeslaCommands()

Expand Down

0 comments on commit be8d13e

Please sign in to comment.