emerald-hws 0.0.7__tar.gz → 0.0.8__tar.gz
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.
- {emerald_hws-0.0.7 → emerald_hws-0.0.8}/PKG-INFO +1 -1
- {emerald_hws-0.0.7 → emerald_hws-0.0.8}/pyproject.toml +3 -8
- {emerald_hws-0.0.7 → emerald_hws-0.0.8}/src/emerald_hws/emeraldhws.py +16 -1
- {emerald_hws-0.0.7 → emerald_hws-0.0.8}/src/emerald_hws.egg-info/PKG-INFO +1 -1
- {emerald_hws-0.0.7 → emerald_hws-0.0.8}/LICENSE +0 -0
- {emerald_hws-0.0.7 → emerald_hws-0.0.8}/README.md +0 -0
- {emerald_hws-0.0.7 → emerald_hws-0.0.8}/setup.cfg +0 -0
- {emerald_hws-0.0.7 → emerald_hws-0.0.8}/src/emerald_hws/__assets__/SFSRootCAG2.pem +0 -0
- {emerald_hws-0.0.7 → emerald_hws-0.0.8}/src/emerald_hws/__init__.py +0 -0
- {emerald_hws-0.0.7 → emerald_hws-0.0.8}/src/emerald_hws.egg-info/SOURCES.txt +0 -0
- {emerald_hws-0.0.7 → emerald_hws-0.0.8}/src/emerald_hws.egg-info/dependency_links.txt +0 -0
- {emerald_hws-0.0.7 → emerald_hws-0.0.8}/src/emerald_hws.egg-info/requires.txt +0 -0
- {emerald_hws-0.0.7 → emerald_hws-0.0.8}/src/emerald_hws.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: emerald_hws
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.8
|
4
4
|
Summary: A package to manipulate and monitor Emerald Heat Pump Hot Water Systems
|
5
5
|
Author-email: Ross Williamson <ross@inertia.net.nz>
|
6
6
|
Project-URL: Homepage, https://github.com/ross-w/emerald_hws_py
|
@@ -4,14 +4,9 @@ build-backend = "setuptools.build_meta"
|
|
4
4
|
|
5
5
|
[project]
|
6
6
|
name = "emerald_hws"
|
7
|
-
version = "0.0.
|
8
|
-
dependencies = [
|
9
|
-
|
10
|
-
"awsiotsdk"
|
11
|
-
]
|
12
|
-
authors = [
|
13
|
-
{ name="Ross Williamson", email="ross@inertia.net.nz" },
|
14
|
-
]
|
7
|
+
version = "0.0.8"
|
8
|
+
dependencies = ["boto3", "awsiotsdk"]
|
9
|
+
authors = [{ name = "Ross Williamson", email = "ross@inertia.net.nz" }]
|
15
10
|
description = "A package to manipulate and monitor Emerald Heat Pump Hot Water Systems"
|
16
11
|
readme = "README.md"
|
17
12
|
requires-python = ">=3.7"
|
@@ -4,6 +4,7 @@ import os
|
|
4
4
|
import logging
|
5
5
|
import boto3
|
6
6
|
import random
|
7
|
+
import threading
|
7
8
|
from awsiot import mqtt5_client_builder, mqtt_connection_builder
|
8
9
|
from awscrt import mqtt5, http, auth, io
|
9
10
|
|
@@ -21,10 +22,11 @@ class EmeraldHWS():
|
|
21
22
|
MQTT_HOST = "a13v32g67itvz9-ats.iot.ap-southeast-2.amazonaws.com"
|
22
23
|
COGNITO_IDENTITY_POOL_ID = "ap-southeast-2:f5bbb02c-c00e-4f10-acb3-e7d1b05268e8"
|
23
24
|
|
24
|
-
def __init__(self, email, password):
|
25
|
+
def __init__(self, email, password, update_callback=None):
|
25
26
|
""" Initialise the API client
|
26
27
|
:param email: The email address for logging into the Emerald app
|
27
28
|
:param password: The password for the supplied user account
|
29
|
+
:param update_callback: Optional callback function to be called when an update is available
|
28
30
|
"""
|
29
31
|
|
30
32
|
self.email = email
|
@@ -32,6 +34,7 @@ class EmeraldHWS():
|
|
32
34
|
self.token = ""
|
33
35
|
self.properties = {}
|
34
36
|
self.logger = logging.getLogger()
|
37
|
+
self.update_callback = update_callback
|
35
38
|
|
36
39
|
def getLoginToken(self):
|
37
40
|
""" Performs an API request to get a token from the API
|
@@ -78,6 +81,15 @@ class EmeraldHWS():
|
|
78
81
|
else:
|
79
82
|
raise Exception("Unable to fetch properties from Emerald API")
|
80
83
|
|
84
|
+
def reconnectMQTT(self):
|
85
|
+
""" Stops an existing MQTT connection and creates a new one
|
86
|
+
"""
|
87
|
+
|
88
|
+
self.logger.debug("emeraldhws: awsiot: Tearing down and reconnecting to prevent stale connection")
|
89
|
+
self.mqttClient.stop()
|
90
|
+
self.connectMQTT()
|
91
|
+
self.subscribeAllHWS()
|
92
|
+
|
81
93
|
def connectMQTT(self):
|
82
94
|
""" Establishes a connection to Amazon IOT core's MQTT service
|
83
95
|
"""
|
@@ -113,6 +125,7 @@ class EmeraldHWS():
|
|
113
125
|
|
114
126
|
client.start()
|
115
127
|
self.mqttClient = client
|
128
|
+
threading.Timer(43200.0, self.reconnectMQTT).start() # 12 hours
|
116
129
|
|
117
130
|
def mqttDecodeUpdate(self, topic, payload):
|
118
131
|
""" Attempt to decode a received MQTT message and direct appropriately
|
@@ -188,6 +201,8 @@ class EmeraldHWS():
|
|
188
201
|
for heat_pump in heat_pumps:
|
189
202
|
if heat_pump['id'] == id:
|
190
203
|
heat_pump['last_state'][key] = value
|
204
|
+
if self.update_callback != None:
|
205
|
+
self.update_callback()
|
191
206
|
|
192
207
|
def subscribeForUpdates(self, id):
|
193
208
|
""" Subscribes to the MQTT topics for the supplied HWS
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: emerald_hws
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.8
|
4
4
|
Summary: A package to manipulate and monitor Emerald Heat Pump Hot Water Systems
|
5
5
|
Author-email: Ross Williamson <ross@inertia.net.nz>
|
6
6
|
Project-URL: Homepage, https://github.com/ross-w/emerald_hws_py
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|