Skip to content

Commit

Permalink
add dynamic qos
Browse files Browse the repository at this point in the history
  • Loading branch information
m4dm4rtig4n committed Sep 25, 2021
1 parent 36845e9 commit 98a6745
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2-dev
0.2
9 changes: 4 additions & 5 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,13 +236,13 @@ def dailyConsumption(client, last_activation_date):
data = dailyConsumptionBeetwen(pdl, dateBegin, dateEnded, last_activation_date)
for key, value in data.items():
publish(client, f"{pdl}/consumption/current_year/{key}", str(value))
ha_autodiscovery(client, "sensor", f"consumption_current_year_{key}", str(value), "W", "energy",
ha_autodiscovery(client, "sensor", f"{pdl}_consumption_current_year_{key}", str(value), "W", "energy",
"total_increasing")
if base_price != False:
if isinstance(value, int):
roundValue = round(int(value) / 1000 * base_price, 2)
publish(client, f"{pdl}/price/current_year/{key}", roundValue)
ha_autodiscovery(client, "sensor", f"price_current_year_{key}", roundValue, "€", 'monetary')
ha_autodiscovery(client, "sensor", f"{pdl}_price_current_year_{key}", roundValue, "€", 'monetary')
lastData = data

current_year = 1
Expand All @@ -262,13 +262,13 @@ def dailyConsumption(client, last_activation_date):
publish(client, f"{pdl}/consumption/year-{current_year}/error", str(0))
for key, value in data.items():
publish(client, f"{pdl}/consumption/year-{current_year}/{key}", str(value))
ha_autodiscovery(client, "sensor", f"consumption_year_{current_year}_{key}", str(value), "W",
ha_autodiscovery(client, "sensor", f"{pdl}_consumption_year_{current_year}_{key}", str(value), "W",
"energy", "total_increasing")
if base_price != False:
if isinstance(value, int):
roundValue = round(int(value) / 1000 * base_price, 2)
publish(client, f"{pdl}/price/year-{current_year}/{key}", roundValue)
ha_autodiscovery(client, "sensor", f"price_year_{current_year}_{key}", roundValue, "€",
ha_autodiscovery(client, "sensor", f"{pdl}_price_year_{current_year}_{key}", roundValue, "€",
'monetary')
if current_year == 1:
queue = "current_year"
Expand Down Expand Up @@ -307,7 +307,6 @@ def dailyConsumptionBeetwen(pdl, dateBegin, dateEnded, last_activation_date):
date = interval_reading['date']
value = interval_reading['value']
mesures[date] = value
# mesure = sorted(mesures, reverse=True)
list_date = list(reversed(sorted(mesures.keys())))

dateEnded = datetime.strptime(dateEnded, '%Y-%m-%d')
Expand Down

0 comments on commit 98a6745

Please sign in to comment.