Skip to content

Commit

Permalink
add ha ws enable
Browse files Browse the repository at this point in the history
  • Loading branch information
m4dm4rtig4n committed Sep 13, 2023
1 parent a3ca4b9 commit e53f784
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
12 changes: 12 additions & 0 deletions app/models/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ def __init__(self, path="/data"):
"enable": False,
"discovery_prefix": "homeassistant",
},
"home_assistant_ws": {
"enable": False,
"ssl": True,
"token": "",
"url": ""
},
"influxdb": {
"enable": False,
"hostname": "influxdb",
Expand Down Expand Up @@ -265,6 +271,12 @@ def home_assistant_config(self):
else:
return False

def home_assistant_ws_config(self):
if "home_assistant_ws" in self.config:
return self.config["home_assistant_ws"]
else:
return False

def influxdb_config(self):
if "influxdb" in self.config:
return self.config["influxdb"]
Expand Down
6 changes: 5 additions & 1 deletion app/models/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def __init__(self, usage_point_id=None):
self.usage_point_config = {}
self.mqtt_config = self.config.mqtt_config()
self.home_assistant_config = self.config.home_assistant_config()
self.home_assistant_ws_config = self.config.home_assistant_ws_config()
self.influxdb_config = self.config.influxdb_config()
self.wait_job_start = 10
self.tempo_enable = False
Expand Down Expand Up @@ -446,7 +447,10 @@ def export_home_assistant_ws(self):
detail = "Import des données vers l'onglet Energy de Home Assistant (WebSocket)"
usage_point_id = self.usage_point_config.usage_point_id
title(f"[{usage_point_id}] {detail}")
HomeAssistantWs(usage_point_id)
if "enable" in self.home_assistant_ws_config and str2bool(self.home_assistant_ws_config["enable"]):
HomeAssistantWs(usage_point_id)
else:
title("Désactivé dans la configuration (Exemple: https://tinyurl.com/2kbd62s9)")

def export_influxdb(self):
detail = "Export InfluxDB"
Expand Down
13 changes: 6 additions & 7 deletions config.exemple.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,15 @@ wipe_influxdb: false # Work only with influxdb > 2.X
# storage_uri: postgresql://myelectricaldata:myelectricaldata@postgres:5432/myelectricaldata
tempo:
enable: true
price_blue_hc: 0.097
price_blue_hp: 0.1249
price_red_hc: 0.1216
price_red_hp: 0.6712
price_white_hc: 0.114
price_white_hp: 0.1508
home_assistant:
home_assistant: # WITH MQTT DISCOVERY
enable: true
discovery: true
discovery_prefix: homeassistant
home_assistant_ws: # FOR ENERGY TAB
enable: true
ssl: true
token: HOME_ASSISTANT_TOKEN_GENERATE_IN_PROFILE_TABS_(BOTTOM)
url: myhomeassistant.domain.fr
influxdb:
enable: true
hostname: influxdb
Expand Down

0 comments on commit e53f784

Please sign in to comment.