juham-automation 0.0.12__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.
Files changed (27) hide show
  1. juham_automation/__init__.py +8 -6
  2. juham_automation/automation/__init__.py +6 -6
  3. juham_automation/automation/energybalancer.py +281 -0
  4. juham_automation/automation/energycostcalculator.py +112 -68
  5. juham_automation/automation/heatingoptimizer.py +971 -0
  6. juham_automation/automation/leakdetector.py +162 -0
  7. juham_automation/automation/watercirculator.py +1 -20
  8. juham_automation/japp.py +4 -2
  9. juham_automation/ts/__init__.py +3 -1
  10. juham_automation/ts/electricityprice_ts.py +1 -1
  11. juham_automation/ts/energybalancer_ts.py +73 -0
  12. juham_automation/ts/energycostcalculator_ts.py +3 -1
  13. juham_automation/ts/log_ts.py +19 -16
  14. juham_automation/ts/power_ts.py +17 -14
  15. juham_automation/ts/powermeter_ts.py +3 -5
  16. juham_automation/ts/powerplan_ts.py +37 -18
  17. juham_automation-0.2.11.dist-info/METADATA +198 -0
  18. juham_automation-0.2.11.dist-info/RECORD +24 -0
  19. {juham_automation-0.0.12.dist-info → juham_automation-0.2.11.dist-info}/WHEEL +1 -1
  20. {juham_automation-0.0.12.dist-info → juham_automation-0.2.11.dist-info}/entry_points.txt +3 -2
  21. juham_automation/automation/hotwateroptimizer.py +0 -567
  22. juham_automation/automation/powermeter_simulator.py +0 -139
  23. juham_automation/automation/spothintafi.py +0 -140
  24. juham_automation-0.0.12.dist-info/METADATA +0 -109
  25. juham_automation-0.0.12.dist-info/RECORD +0 -23
  26. {juham_automation-0.0.12.dist-info → juham_automation-0.2.11.dist-info/licenses}/LICENSE.rst +0 -0
  27. {juham_automation-0.0.12.dist-info → juham_automation-0.2.11.dist-info}/top_level.txt +0 -0
@@ -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)
@@ -1,109 +0,0 @@
1
- Metadata-Version: 2.2
2
- Name: juham-automation
3
- Version: 0.0.12
4
- Summary: Juha's Ultimate Home Automation Masterpiece
5
- Author-email: J Meskanen <juham.api@gmail.com>
6
- Maintainer-email: "J. Meskanen" <juham.api@gmail.com>
7
- License: LICENSE
8
- =======
9
-
10
- Copyright (c) 2024, Juha Meskanen
11
-
12
- Permission is hereby granted, free of charge, to any person obtaining
13
- a copy of this software and associated documentation files (the
14
- "Software"), to deal in the Software without restriction, including
15
- without limitation the rights to use, copy, modify, merge, publish,
16
- distribute, sublicense, and/or sell copies of the Software, and to
17
- permit persons to whom the Software is furnished to do so, subject to
18
- the following conditions:
19
-
20
- **The above copyright notice and this permission notice shall be included in all
21
- copies or substantial portions of the Software.**
22
-
23
-
24
- ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
27
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
28
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
29
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
30
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. **
31
-
32
-
33
- Project-URL: Homepage, https://gitlab.com/juham/juham/juham-automation.git
34
- Project-URL: Bug Reports, https://gitlab.com/juham/juham/juham-automation.git
35
- Project-URL: Funding, https://meskanen.com
36
- Project-URL: Say Thanks!, http://meskanen.com
37
- Project-URL: Source, https://gitlab.com/juham/juham/juham-automation.git
38
- Keywords: home,automation,juham
39
- Classifier: Development Status :: 2 - Pre-Alpha
40
- Classifier: Intended Audience :: Developers
41
- Classifier: Topic :: Software Development
42
- Classifier: License :: Public Domain
43
- Classifier: Programming Language :: Python :: 3.8
44
- Requires-Python: >=3.8
45
- Description-Content-Type: text/markdown
46
- License-File: LICENSE.rst
47
- Requires-Dist: masterpiece_influx>=0.1.9
48
- Requires-Dist: masterpiece_pahomqtt>=0.1.5
49
- Requires-Dist: juham_core>=0.1.1
50
- Requires-Dist: requests>=2.31
51
- Requires-Dist: pytz>=2024.1
52
- Provides-Extra: dev
53
- Requires-Dist: check-manifest; extra == "dev"
54
- Requires-Dist: types-pyz; extra == "dev"
55
-
56
- Welcome to Juham™ - Juha's Ultimate Home Automation Masterpiece
57
- ================================================================
58
-
59
- Project Description
60
- -------------------
61
-
62
- This package extends the ``juham_core`` package, providing home automation building blocks that cover most common needs.
63
- It consists of two main sub-modules:
64
-
65
- .. image:: _static/images/juham_automation.png
66
- :alt: Basic automation classes for optimizing energy consumption and minimizing electricity costs.
67
- :width: 640px
68
- :align: center
69
-
70
-
71
- - ``automation``
72
-
73
- * **spothintafi**: Acquires electricity prices in Finland.
74
- * **watercirculator**: Automates a water circulator pump based on hot water temperature and motion detection.
75
- * **hotwateroptimizer**: Controls hot water radiators based on temperature sensors and electricity price data.
76
- * **energycostcalculator**: Monitors power consumption and electricity prices, and computes the energy balance in euros.
77
-
78
-
79
- - ``ts``
80
-
81
- * This folder contains time series recorders that listen for Juham™ topics and store the data in a time series database
82
- for later inspection.
83
-
84
-
85
- Project Status
86
- --------------
87
-
88
- **Current State**: **Pre-Alpha (Status 2)**
89
-
90
- All classes have been tested to some extent, and no known bugs have been reported. However, the code still requires work in
91
- terms of design and robustness. For instance, electricity prices are currently hard-coded to use euros, but this should be
92
- configurable to support multiple currencies.
93
-
94
-
95
- Special Thanks
96
- --------------
97
-
98
- This project would not have been possible without the generous support of two exceptional individuals: Teppo K. and Mahi.
99
-
100
- Teppo K. provided the initial spark for this project by donating a Raspberry Pi, a temperature sensor, and giving an inspiring
101
- demonstration of his own home automation system—effectively dragging me down the rabbit hole of endless tinkering.
102
-
103
- Mahi has been instrumental in translating my half-baked ideas into Python code, offering invaluable support and
104
- encouragement—while also ensuring that every time I thought I was done, I wasn’t.
105
-
106
- Because of these two gentlemen, my already minimal spare time dropped into the negatives as I desperately tried to push the
107
- system to some semblance of professionalism.
108
-
109
- I’m truly grateful to both—really. 😅
@@ -1,23 +0,0 @@
1
- juham_automation/__init__.py,sha256=FSk6iuBWwWckbT_brwQNSzOQ8MrzyufVXxDRFZRdRwk,812
2
- juham_automation/japp.py,sha256=DuxMpoI3u9xP5-HaF1s3xI29PWa05jzBcOR8JNn0M0U,1471
3
- juham_automation/py.typed,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
4
- juham_automation/automation/__init__.py,sha256=HV67cq9oXTcoAk5uBbHw3F1vR_saKztsHQxlFizqnHQ,460
5
- juham_automation/automation/energycostcalculator.py,sha256=R9BjsPw04ZxmpYEnn67zqiQzGFQYVT6bq-S2b3x6trg,10825
6
- juham_automation/automation/hotwateroptimizer.py,sha256=FNRukp-a4dPiw8TUEiaCzrSfBNzaAO8wyHu4TUu35FU,21833
7
- juham_automation/automation/powermeter_simulator.py,sha256=3WZcjByRTdqnC77l7LjP-TEjmZ8XBEO4hClYsrjxmBE,4549
8
- juham_automation/automation/spothintafi.py,sha256=cZbi7w2fVweHX_fh1r5MTjGdesX9wDQta2mfVjtiwvw,4331
9
- juham_automation/automation/watercirculator.py,sha256=a8meMNaONbHcIH3y0vP0UulJc1-gZiLZpw7H8kAOreY,6410
10
- juham_automation/ts/__init__.py,sha256=SinjhBcaRVP5FUyCMFWJGR3P7ZetL7ya8-VqhRb2skg,525
11
- juham_automation/ts/electricityprice_ts.py,sha256=BYs120V4teVjSqPc8PpPDjOTc5dOrVM9Maqse7E8cvk,1684
12
- juham_automation/ts/energycostcalculator_ts.py,sha256=MbeYEGlziVgq4zI40Tk71zxeDPeKafEG3s0LqDRiz0g,1277
13
- juham_automation/ts/forecast_ts.py,sha256=Gk46hIlS8ijxs-zyy8fBvXrhI7J-8e5Gt2QEe6gFB6s,3158
14
- juham_automation/ts/log_ts.py,sha256=XsNaazuPmRUZLUqxU0DZae_frtT6kAFcXJTc598CtOA,1750
15
- juham_automation/ts/power_ts.py,sha256=e7bSeZjitY4C_gLup9L0NjvU_WnQsl3ayDhVShj32KY,1399
16
- juham_automation/ts/powermeter_ts.py,sha256=wkCROQj9kXHgDdMuIbbAjhgP5Pr6TA6eT2T-r9sHidw,2351
17
- juham_automation/ts/powerplan_ts.py,sha256=LZeE7TnzPCDaugggKlaV-K48lDwwnC1ZNum50JYAWaY,1482
18
- juham_automation-0.0.12.dist-info/LICENSE.rst,sha256=QVHD5V5_HSys2PdPdig_xKggDj8cGX33ALKqRsYyjtI,1089
19
- juham_automation-0.0.12.dist-info/METADATA,sha256=N8gB9QmKA57s9T5J6J2fNNGJFlipzIVwbCXyt_aCGRQ,4747
20
- juham_automation-0.0.12.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
21
- juham_automation-0.0.12.dist-info/entry_points.txt,sha256=di8tXChhP8B_98bQ44u-1zkOha2kZCoJpCAXxTgoSw8,491
22
- juham_automation-0.0.12.dist-info/top_level.txt,sha256=jfohvtocvX_gfT21AhJk7Iay5ZiQsS3HzrDjF7S4Qp0,17
23
- juham_automation-0.0.12.dist-info/RECORD,,