juham-automation 0.2.8__py3-none-any.whl → 0.2.11__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.
@@ -7,7 +7,6 @@ Juham - Juha's Ultimate Home Automation Masterpiece
7
7
  """
8
8
 
9
9
  from .automation import EnergyCostCalculator
10
- from .automation import SpotHintaFi
11
10
  from .automation import WaterCirculator
12
11
  from .automation import HeatingOptimizer
13
12
  from .automation import EnergyBalancer
@@ -34,7 +33,6 @@ __all__ = [
34
33
  "PowerTs",
35
34
  "PowerPlanTs",
36
35
  "PowerMeterTs",
37
- "SpotHintaFi",
38
36
  "WaterCirculator",
39
37
  "JApp",
40
38
  "ElectricityPriceTs",
@@ -7,7 +7,6 @@ Juham - Juha's Ultimate Home Automation classes
7
7
  """
8
8
 
9
9
  from .energycostcalculator import EnergyCostCalculator
10
- from .spothintafi import SpotHintaFi
11
10
  from .watercirculator import WaterCirculator
12
11
  from .heatingoptimizer import HeatingOptimizer
13
12
  from .energybalancer import EnergyBalancer
@@ -16,7 +15,6 @@ from .leakdetector import LeakDetector
16
15
  __all__ = [
17
16
  "EnergyCostCalculator",
18
17
  "HeatingOptimizer",
19
- "SpotHintaFi",
20
18
  "WaterCirculator",
21
19
  "EnergyBalancer",
22
20
  "LeakDetector",
juham_automation/japp.py CHANGED
@@ -10,7 +10,6 @@ from .ts import EnergyBalancerTs
10
10
  from .ts import LogTs
11
11
  from .ts import EnergyCostCalculatorTs
12
12
  from .ts import ElectricityPriceTs
13
- from .automation import SpotHintaFi
14
13
  from .automation import EnergyCostCalculator
15
14
 
16
15
 
@@ -40,7 +39,6 @@ class JApp(Application):
40
39
  self.add(PowerPlanTs())
41
40
  self.add(PowerMeterTs())
42
41
  self.add(LogTs())
43
- self.add(SpotHintaFi())
44
42
  self.add(EnergyCostCalculator())
45
43
  self.add(EnergyCostCalculatorTs())
46
44
  self.add(ElectricityPriceTs())
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: juham-automation
3
- Version: 0.2.8
3
+ Version: 0.2.11
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>
@@ -18,7 +18,7 @@ Classifier: Programming Language :: Python :: 3.8
18
18
  Requires-Python: >=3.8
19
19
  Description-Content-Type: text/markdown
20
20
  License-File: LICENSE.rst
21
- Requires-Dist: juham_core>=0.2.4
21
+ Requires-Dist: juham_core>=0.2.6
22
22
  Provides-Extra: dev
23
23
  Requires-Dist: check-manifest; extra == "dev"
24
24
  Requires-Dist: coverage>=7.0; extra == "dev"
@@ -38,7 +38,6 @@ It consists of two main sub-modules:
38
38
 
39
39
  This folder contains automation classes that listen to Juham™ MQTT topics and control various home automation tasks.
40
40
 
41
- - **spothintafi**: Acquires electricity prices in Finland.
42
41
  - **watercirculator**: Automates a water circulator pump based on hot water temperature and motion detection.
43
42
  - **heatingoptimizer**: Controls hot water radiators based on temperature sensors and electricity price data.
44
43
  - **energycostcalculator**: Monitors power consumption and electricity prices, and computes the energy balance in euros.
@@ -1,12 +1,11 @@
1
- juham_automation/__init__.py,sha256=Y_fUDerXnXFkv1z2p7FeqKQlJ2EuIDY6AEK7xVQ1tXE,914
2
- juham_automation/japp.py,sha256=L2u1mfKvun2fiXhB3AEJD9zMDcdFZ3_doXZYJJzu9tg,1646
1
+ juham_automation/__init__.py,sha256=pe0JYVYlrusLGrKxUBHo7lW8pNMk_7mCQGtQAFepsYw,859
2
+ juham_automation/japp.py,sha256=e8kXkvAeWFz54gBH2lk9fa4ONd3XP_gQyVKVuSJ4BtM,1578
3
3
  juham_automation/py.typed,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
4
- juham_automation/automation/__init__.py,sha256=0FYYSo2qSMMibH5YHIFgdT6gc5Cmf8XlpQHFSrswE5I,500
4
+ juham_automation/automation/__init__.py,sha256=qA4iU1nhL2IKP6uJ3nJq_SGYxrjEfCoCGb1U8ocmAoM,444
5
5
  juham_automation/automation/energybalancer.py,sha256=Kw0Czah4JLOgDVAx6ca4nJpFpfZa9LXmv6pr612f-Fg,11473
6
6
  juham_automation/automation/energycostcalculator.py,sha256=96pidMxi4tK9g8iLepn9XuTeauZhxi74qGXvvQJe-6s,13023
7
7
  juham_automation/automation/heatingoptimizer.py,sha256=AO1VHBHfgQJ8kENsgZH3O3GHZjSksQx_CrsdZZoxjoM,39038
8
8
  juham_automation/automation/leakdetector.py,sha256=Q-3X0NOFJf0C5MlR7R_QQp8yw5XvTt85oduuTRYIu_0,6003
9
- juham_automation/automation/spothintafi.py,sha256=cZbi7w2fVweHX_fh1r5MTjGdesX9wDQta2mfVjtiwvw,4331
10
9
  juham_automation/automation/watercirculator.py,sha256=QcLAP9oLA-tYYRH2SjnPT6_kIOdiQbOSf2tQPMitEN0,5471
11
10
  juham_automation/ts/__init__.py,sha256=kTEzVkDi6ednH4-fxKxrY6enlTuTXmSw09pPAQX3CMc,612
12
11
  juham_automation/ts/electricityprice_ts.py,sha256=kRIewAAtTPi5JvHLEgGGVp_28LkWyB6lGyUH_2dKqBQ,1677
@@ -17,9 +16,9 @@ juham_automation/ts/log_ts.py,sha256=GLOqnwmk2cJdoWPWlrC3XAADp-N1JdfZ407YNQxnxhA
17
16
  juham_automation/ts/power_ts.py,sha256=_i_mBPtaVFfH9ycv426uQ4VtSzHacLJB6mEApe26fhE,1571
18
17
  juham_automation/ts/powermeter_ts.py,sha256=a4sVERj7k397QlJF_VFg-S7DXSg8oAanPcxdYQBzN4w,2218
19
18
  juham_automation/ts/powerplan_ts.py,sha256=TXD4aI8TAv2oGrbHZRjxkhrWkOubJ4Lq3sdotsgAn2Q,2358
20
- juham_automation-0.2.8.dist-info/licenses/LICENSE.rst,sha256=QVHD5V5_HSys2PdPdig_xKggDj8cGX33ALKqRsYyjtI,1089
21
- juham_automation-0.2.8.dist-info/METADATA,sha256=swuuGZKrrFBlQCoJDqOUkPJVGJ5wqPOgk2OK-NcmOQs,7620
22
- juham_automation-0.2.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
23
- juham_automation-0.2.8.dist-info/entry_points.txt,sha256=h-KzuKjmGPd4_iX_oiGvxx4IEc97dVbGGlhdh5ctbpI,605
24
- juham_automation-0.2.8.dist-info/top_level.txt,sha256=jfohvtocvX_gfT21AhJk7Iay5ZiQsS3HzrDjF7S4Qp0,17
25
- juham_automation-0.2.8.dist-info/RECORD,,
19
+ juham_automation-0.2.11.dist-info/licenses/LICENSE.rst,sha256=QVHD5V5_HSys2PdPdig_xKggDj8cGX33ALKqRsYyjtI,1089
20
+ juham_automation-0.2.11.dist-info/METADATA,sha256=C4gTUMdYu2wpqTU53rey0i9tUnDWQiFScUXNgHr-R7M,7562
21
+ juham_automation-0.2.11.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
22
+ juham_automation-0.2.11.dist-info/entry_points.txt,sha256=rM4wM2dDeJ2LatuqJ4JKKX8rNrcbd3wVUtT9MNphdlc,555
23
+ juham_automation-0.2.11.dist-info/top_level.txt,sha256=jfohvtocvX_gfT21AhJk7Iay5ZiQsS3HzrDjF7S4Qp0,17
24
+ juham_automation-0.2.11.dist-info/RECORD,,
@@ -9,4 +9,3 @@ logts_plugin = juham_automation:LogTs
9
9
  powerplan_plugin = juham_automation:PowerPlanTs
10
10
  powerts_plugin = juham_automation:PowerTs
11
11
  rwatercirculator_plugin = juham_automation:WaterCirculator
12
- spothintafi_plugin = juham_automation:SpotHintaFi
@@ -1,140 +0,0 @@
1
- from datetime import datetime
2
- import time
3
- import json
4
- from typing import Any, Dict, Optional, cast
5
- from typing_extensions import override
6
-
7
- from masterpiece.mqtt import Mqtt, MqttMsg
8
- from juham_core import JuhamCloudThread, JuhamThread
9
-
10
-
11
- class SpotHintaFiThread(JuhamCloudThread):
12
- """Thread running SpotHinta.fi.
13
-
14
- Periodically fetches the spot electricity prices and publishes them
15
- to 'spot' topic.
16
- """
17
-
18
- _spot_topic: str = ""
19
- _url: str = ""
20
- _interval: float = 12 * 3600
21
- grid_cost_day: float = 0.0314
22
- grid_cost_night: float = 0.0132
23
- grid_cost_tax: float = 0.028272
24
-
25
- def __init__(self, client: Optional[Mqtt] = None) -> None:
26
- super().__init__(client)
27
- self._interval = 60
28
-
29
- def init(self, topic: str, url: str, interval: float) -> None:
30
- self._spot_topic = topic
31
- self._url = url
32
- self._interval = interval
33
-
34
- @override
35
- def make_weburl(self) -> str:
36
- return self._url
37
-
38
- @override
39
- def update_interval(self) -> float:
40
- return self._interval
41
-
42
- @override
43
- def process_data(self, rawdata: Any) -> None:
44
- """Publish electricity price message to Juham topic.
45
-
46
- Args:
47
- rawdata (dict): electricity prices
48
- """
49
-
50
- super().process_data(rawdata)
51
- data = rawdata.json()
52
-
53
- spot = []
54
- for e in data:
55
- dt = datetime.fromisoformat(e["DateTime"]) # Correct timezone handling
56
- ts = int(dt.timestamp()) # Ensure integer timestamps like in the test
57
-
58
- hour = dt.strftime("%H") # Correctly extract hour
59
-
60
- if 6 <= int(hour) < 22:
61
- grid_cost = self.grid_cost_day
62
- else:
63
- grid_cost = self.grid_cost_night
64
-
65
- total_price = round(e["PriceWithTax"] + grid_cost + self.grid_cost_tax, 6)
66
- grid_cost_total = round(grid_cost + self.grid_cost_tax, 6)
67
-
68
- h = {
69
- "Timestamp": ts,
70
- "hour": hour,
71
- "Rank": e["Rank"],
72
- "PriceWithTax": total_price,
73
- "GridCost": grid_cost_total,
74
- }
75
- spot.append(h)
76
-
77
- self.publish(self._spot_topic, json.dumps(spot), 1, True)
78
- # self.info(f"Spot electricity prices published for the next {len(spot)} days")
79
-
80
-
81
- class SpotHintaFi(JuhamThread):
82
- """Spot electricity price for reading hourly electricity prices from
83
- https://api.spot-hinta.fi site.
84
- """
85
-
86
- _SPOTHINTAFI: str = "_spothintafi"
87
- worker_thread_id = SpotHintaFiThread.get_class_id()
88
- url = "https://api.spot-hinta.fi/TodayAndDayForward"
89
- update_interval = 12 * 3600
90
-
91
- def __init__(self, name: str = "rspothintafi") -> None:
92
- super().__init__(name)
93
- self.active_liter_lpm = -1
94
- self.update_ts = None
95
- self.spot_topic = self.make_topic_name("spot")
96
-
97
- @override
98
- def on_connect(self, client: object, userdata: Any, flags: int, rc: int) -> None:
99
- super().on_connect(client, userdata, flags, rc)
100
- if rc == 0:
101
- self.subscribe(self.spot_topic)
102
-
103
- @override
104
- def on_message(self, client: object, userdata: Any, msg: MqttMsg) -> None:
105
- if msg.topic == self.spot_topic:
106
- em = json.loads(msg.payload.decode())
107
- self.on_spot(em)
108
- else:
109
- super().on_message(client, userdata, msg)
110
-
111
- def on_spot(self, m: dict[Any, Any]) -> None:
112
- """Write hourly spot electricity prices to time series database.
113
-
114
- Args:
115
- m (dict): holding hourly spot electricity prices
116
- """
117
- pass
118
-
119
- @override
120
- def run(self) -> None:
121
- self.worker = cast(SpotHintaFiThread, self.instantiate(self.worker_thread_id))
122
- self.worker.init(self.spot_topic, self.url, self.update_interval)
123
- super().run()
124
-
125
- @override
126
- def to_dict(self) -> Dict[str, Any]:
127
- data: Dict[str, Any] = super().to_dict()
128
- data[self._SPOTHINTAFI] = {
129
- "topic": self.spot_topic,
130
- "url": self.url,
131
- "interval": self.update_interval,
132
- }
133
- return data
134
-
135
- @override
136
- def from_dict(self, data: Dict[str, Any]) -> None:
137
- super().from_dict(data)
138
- if self._SPOTHINTAFI in data:
139
- for key, value in data[self._SPOTHINTAFI].items():
140
- setattr(self, key, value)