juham-automation 0.0.33__py3-none-any.whl → 0.0.34__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,7 +14,7 @@ class Consumer:
14
14
 
15
15
  """
16
16
 
17
- def __init__(self, name: str, power: float) -> None:
17
+ def __init__(self, name: str, power: float, weight: float) -> None:
18
18
  """Initialize the consumer
19
19
 
20
20
  Args:
@@ -25,6 +25,7 @@ class Consumer:
25
25
  self.power: float = power
26
26
  self.start: float = 0.0
27
27
  self.stop: float = 0.0
28
+ self.weight: float = weight
28
29
 
29
30
 
30
31
  class EnergyBalancer(Juham):
@@ -102,8 +103,10 @@ class EnergyBalancer(Juham):
102
103
  m (dict[str, Any]): power consumer message
103
104
  ts (float): current time
104
105
  """
105
- self.consumers[m["Unit"]] = Consumer(m["Unit"], m["Power"])
106
- self.info(f"Consumer {m['Unit']} added, power: {m['Power']}")
106
+ self.consumers[m["Unit"]] = Consumer(m["Unit"], m["Power"], m["Weight"])
107
+ self.info(
108
+ f"Consumer {m['Unit']} added, power: {m['Power']}, weight: {m['Weight']}"
109
+ )
107
110
 
108
111
  def update_energy_balance(self, power: float, ts: float) -> None:
109
112
  """Update the current net net energy balance. The change in the balance is calculate the
@@ -164,8 +167,16 @@ class EnergyBalancer(Juham):
164
167
  remaining_ts_consumer: float = (
165
168
  self.energy_balancing_interval - interval_ts
166
169
  ) / num_consumers
170
+ total_weight: float = 0.0
171
+ for consumer in self.consumers.values():
172
+ total_weight += consumer.weight
173
+ equal_weight: float = total_weight / num_consumers
167
174
  for consumer in self.consumers.values():
168
- required_power += consumer.power * remaining_ts_consumer
175
+ required_power += (
176
+ (consumer.weight / equal_weight)
177
+ * consumer.power
178
+ * remaining_ts_consumer
179
+ )
169
180
  return required_power
170
181
 
171
182
  def initialize_consumer_timelines(self, ts: float) -> None:
@@ -185,9 +196,16 @@ class EnergyBalancer(Juham):
185
196
  self.energy_balancing_interval - interval_ts
186
197
  ) / num_consumers
187
198
 
199
+ total_weight: float = 0.0
200
+ for consumer in self.consumers.values():
201
+ total_weight += consumer.weight
202
+ equal_weight: float = total_weight / num_consumers
203
+
188
204
  for consumer in self.consumers.values():
189
205
  consumer.start = interval_ts
190
- consumer.stop = interval_ts + secs_per_consumer
206
+ consumer.stop = (
207
+ interval_ts + secs_per_consumer * consumer.weight / equal_weight
208
+ )
191
209
  interval_ts += secs_per_consumer
192
210
 
193
211
  def publish_energybalance(self, ts: float) -> None:
@@ -220,6 +238,7 @@ class EnergyBalancer(Juham):
220
238
  "Unit": consumer.name,
221
239
  "Power": consumer.power,
222
240
  "Mode": consumer.start <= interval_ts < consumer.stop,
241
+ "Weight": consumer.weight,
223
242
  "Timestamp": ts,
224
243
  }
225
244
  self.publish(self.topic_out_status, json.dumps(m))
@@ -57,6 +57,9 @@ class HeatingOptimizer(Juham):
57
57
  uoi_threshold: float = 0.8
58
58
  """Utilization Optimization Index threshold. This is the minimum UOI value that is allowed for the heating to be activated."""
59
59
 
60
+ balancing_weight: float = 1.0
61
+ """Weight determining how large a share of the time slot a consumer receives compared to others ."""
62
+
60
63
  temperature_limits: dict[int, tuple[float, float]] = {
61
64
  1: (20.0, 60.0), # January
62
65
  2: (20.0, 60.0), # February
@@ -153,6 +156,7 @@ class HeatingOptimizer(Juham):
153
156
  consumer: dict[str, Any] = {
154
157
  "Unit": self.name,
155
158
  "Power": self.radiator_power,
159
+ "Weight": self.balancing_weight,
156
160
  }
157
161
  self.publish(self.topic_out_energybalance, json.dumps(consumer), 1, False)
158
162
  self.info(
@@ -300,7 +304,7 @@ class HeatingOptimizer(Juham):
300
304
  self.relay_started_ts = ts_utc_now
301
305
 
302
306
  if not self.ranked_spot_prices:
303
- self.debug("{self.name} waiting spot prices...", "")
307
+ self.debug(f"{self.name} waiting spot prices...", "")
304
308
  return
305
309
 
306
310
  if not self.power_plan:
@@ -312,7 +316,7 @@ class HeatingOptimizer(Juham):
312
316
  )
313
317
 
314
318
  if not self.power_plan:
315
- self.error("{self.name} failed to create a power plan", "")
319
+ self.error(f"{self.name} failed to create a power plan", "")
316
320
  return
317
321
 
318
322
  if len(self.power_plan) < 3:
@@ -333,7 +337,7 @@ class HeatingOptimizer(Juham):
333
337
  if not self.heating_plan:
334
338
  self.heating_plan = self.create_heating_plan()
335
339
  if not self.heating_plan:
336
- self.error("{self.name} failed to create heating plan")
340
+ self.error(f"{self.name} failed to create heating plan")
337
341
  return
338
342
  else:
339
343
  self.info(
@@ -391,7 +395,7 @@ class HeatingOptimizer(Juham):
391
395
  # check if we have excess energy to spent within the current slot
392
396
  if self.net_energy_balance_mode:
393
397
  self.debug(
394
- "{self.name} with positive net energy balance, spend it for heating"
398
+ f"{self.name} with positive net energy balance, spend it for heating"
395
399
  )
396
400
  return 1
397
401
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: juham-automation
3
- Version: 0.0.33
3
+ Version: 0.0.34
4
4
  Summary: Juha's Ultimate Home Automation Masterpiece
5
5
  Author-email: J Meskanen <juham.api@gmail.com>
6
6
  Maintainer-email: "J. Meskanen" <juham.api@gmail.com>
@@ -2,9 +2,9 @@ juham_automation/__init__.py,sha256=32BL36bhT7OaSw22H7st-7-3IXcFM2Pf5js80hNA8W0,
2
2
  juham_automation/japp.py,sha256=L2u1mfKvun2fiXhB3AEJD9zMDcdFZ3_doXZYJJzu9tg,1646
3
3
  juham_automation/py.typed,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
4
4
  juham_automation/automation/__init__.py,sha256=uxkIrcRSp1cFikn-oBRtQ8XiT9cSf7xjm3CS1RN7lAQ,522
5
- juham_automation/automation/energybalancer.py,sha256=2WnnajZdZZjHqUT9onCQCdkAIy_1nom8-y3u_pv2GM0,10844
5
+ juham_automation/automation/energybalancer.py,sha256=VcoDYtQbZC54Fv6u0EfM6DcPYupd9nlDT0Znn3-6ml4,11533
6
6
  juham_automation/automation/energycostcalculator.py,sha256=v30wxRpuY2gGBSMJifrFRTjsRU9t-iCiq33Vds7s3O8,10877
7
- juham_automation/automation/heatingoptimizer.py,sha256=DU-VvEHEZAj3C6CkT6K-7f-LhkAXRBYdf6RoxKbgydc,24412
7
+ juham_automation/automation/heatingoptimizer.py,sha256=X7BY40NoCes3aRz5tKRuEHMRi3TVtcxkgIYffp3_k14,24601
8
8
  juham_automation/automation/powermeter_simulator.py,sha256=3WZcjByRTdqnC77l7LjP-TEjmZ8XBEO4hClYsrjxmBE,4549
9
9
  juham_automation/automation/spothintafi.py,sha256=cZbi7w2fVweHX_fh1r5MTjGdesX9wDQta2mfVjtiwvw,4331
10
10
  juham_automation/automation/watercirculator.py,sha256=a8meMNaONbHcIH3y0vP0UulJc1-gZiLZpw7H8kAOreY,6410
@@ -17,9 +17,9 @@ juham_automation/ts/log_ts.py,sha256=XsNaazuPmRUZLUqxU0DZae_frtT6kAFcXJTc598CtOA
17
17
  juham_automation/ts/power_ts.py,sha256=e7bSeZjitY4C_gLup9L0NjvU_WnQsl3ayDhVShj32KY,1399
18
18
  juham_automation/ts/powermeter_ts.py,sha256=gXzfK2S4SzrQ9GqM0tsLaV6z_vYmTkBatTcaivASSXs,2188
19
19
  juham_automation/ts/powerplan_ts.py,sha256=LZeE7TnzPCDaugggKlaV-K48lDwwnC1ZNum50JYAWaY,1482
20
- juham_automation-0.0.33.dist-info/licenses/LICENSE.rst,sha256=QVHD5V5_HSys2PdPdig_xKggDj8cGX33ALKqRsYyjtI,1089
21
- juham_automation-0.0.33.dist-info/METADATA,sha256=paKzowab6A0iDnu5qduBVXOWofockK1LhXp2KzcSnX4,6837
22
- juham_automation-0.0.33.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
23
- juham_automation-0.0.33.dist-info/entry_points.txt,sha256=h-KzuKjmGPd4_iX_oiGvxx4IEc97dVbGGlhdh5ctbpI,605
24
- juham_automation-0.0.33.dist-info/top_level.txt,sha256=jfohvtocvX_gfT21AhJk7Iay5ZiQsS3HzrDjF7S4Qp0,17
25
- juham_automation-0.0.33.dist-info/RECORD,,
20
+ juham_automation-0.0.34.dist-info/licenses/LICENSE.rst,sha256=QVHD5V5_HSys2PdPdig_xKggDj8cGX33ALKqRsYyjtI,1089
21
+ juham_automation-0.0.34.dist-info/METADATA,sha256=LTcnFtw37Rf299ItV-STdD0g4hCaykQW0Gf7YUMjGg0,6837
22
+ juham_automation-0.0.34.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
23
+ juham_automation-0.0.34.dist-info/entry_points.txt,sha256=h-KzuKjmGPd4_iX_oiGvxx4IEc97dVbGGlhdh5ctbpI,605
24
+ juham_automation-0.0.34.dist-info/top_level.txt,sha256=jfohvtocvX_gfT21AhJk7Iay5ZiQsS3HzrDjF7S4Qp0,17
25
+ juham_automation-0.0.34.dist-info/RECORD,,