-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e3460a0
commit 4842246
Showing
26 changed files
with
1,057 additions
and
261 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "gridworks-protocol" | ||
version = "0.5.8.dev0" | ||
version = "0.5.8.dev1" | ||
description = "Gridworks Protocol" | ||
authors = ["Jessica Millar <[email protected]>"] | ||
license = "MIT" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from gwproto.data_classes.component_attribute_class import ComponentAttributeClass | ||
|
||
|
||
class FibaroSmartImplantCac(ComponentAttributeClass): | ||
... |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from gwproto.data_classes.component_attribute_class import ComponentAttributeClass | ||
|
||
|
||
class HubitatCac(ComponentAttributeClass): | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from gwproto.data_classes.component_attribute_class import ComponentAttributeClass | ||
|
||
|
||
class HubitatTankModuleCac(ComponentAttributeClass): | ||
... |
19 changes: 19 additions & 0 deletions
19
src/gwproto/data_classes/components/fibaro_smart_implant_component.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from typing import Optional | ||
|
||
from gwproto.data_classes.component import Component | ||
|
||
|
||
class FibaroSmartImplantComponent(Component): | ||
def __init__( | ||
self, | ||
component_id: str, | ||
component_attribute_class_id: str, | ||
display_name: Optional[str] = None, | ||
hw_uid: Optional[str] = None, | ||
): | ||
super().__init__( | ||
component_id=component_id, | ||
component_attribute_class_id=component_attribute_class_id, | ||
display_name=display_name, | ||
hw_uid=hw_uid, | ||
) |
30 changes: 0 additions & 30 deletions
30
src/gwproto/data_classes/components/fibaro_tank_temp_sensor_component.py
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from typing import Optional | ||
|
||
from gwproto.data_classes.component import Component | ||
|
||
|
||
class HubitatComponent(Component): | ||
host: str | ||
maker_api_id: int | ||
access_token: str | ||
|
||
def __init__( | ||
self, | ||
component_id: str, | ||
component_attribute_class_id: str, | ||
host: str, | ||
maker_api_id: int, | ||
access_token: str, | ||
display_name: Optional[str] = None, | ||
hw_uid: Optional[str] = None, | ||
): | ||
self.host = host | ||
self.maker_api_id = maker_api_id | ||
self.access_token = access_token | ||
super().__init__( | ||
component_id=component_id, | ||
component_attribute_class_id=component_attribute_class_id, | ||
display_name=display_name, | ||
hw_uid=hw_uid, | ||
) |
83 changes: 83 additions & 0 deletions
83
src/gwproto/data_classes/components/hubitat_tank_component.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
from typing import Optional | ||
|
||
from gwproto.data_classes.component import Component | ||
from gwproto.data_classes.sh_node import ShNode | ||
from gwproto.types.hubitat_component_gt import HubitatComponentGt | ||
from gwproto.types.hubitat_component_gt import HubitatRESTResolutionSettings | ||
from gwproto.types.hubitat_tank_gt import DEFAULT_SENSOR_NODE_NAME_FORMAT | ||
from gwproto.types.hubitat_tank_gt import FibaroTempSensorSettings | ||
from gwproto.types.hubitat_tank_gt import FibaroTempSensorSettingsGt | ||
from gwproto.types.hubitat_tank_gt import HubitatTankSettingsGt | ||
|
||
|
||
class HubitatTankComponent(Component): | ||
hubitat: HubitatComponentGt | ||
devices_gt: list[FibaroTempSensorSettingsGt] | ||
devices: list[FibaroTempSensorSettings] = [] | ||
|
||
def __init__( | ||
self, | ||
component_id: str, | ||
component_attribute_class_id: str, | ||
tank_gt: HubitatTankSettingsGt, | ||
display_name: Optional[str] = None, | ||
hw_uid: Optional[str] = None, | ||
): | ||
# Create self.hubitat as a proxy containing only the id | ||
# of the hubitat; the actual component data will be resolved | ||
# when resolve() is called; Here in the constructor we cannot | ||
# rely on the actual HubitatComponentGt existing yet. | ||
self.hubitat = HubitatComponentGt( | ||
ComponentId=tank_gt.hubitat_component_id, | ||
ComponentAttributeClassId="", | ||
Host="", | ||
MakerApiId=0, | ||
AccessToken="", | ||
) | ||
self.devices_gt = list(tank_gt.devices) | ||
super().__init__( | ||
display_name=display_name, | ||
component_id=component_id, | ||
hw_uid=hw_uid, | ||
component_attribute_class_id=component_attribute_class_id, | ||
) | ||
|
||
def resolve( | ||
self, | ||
tank_node_name: str, | ||
components: dict[str, Component], | ||
nodes: dict[str, ShNode], | ||
node_name_format=DEFAULT_SENSOR_NODE_NAME_FORMAT, | ||
): | ||
hubitat_component = components.get(self.hubitat.ComponentId, None) | ||
if hubitat_component is None: | ||
raise ValueError( | ||
"ERROR. No component found for " | ||
f"HubitatTankComponent.hubitat.CompnentId {self.hubitat.ComponentId}" | ||
) | ||
if not isinstance(hubitat_component, HubitatComponentGt): | ||
raise ValueError( | ||
"ERROR. Referenced hubitat component has type " | ||
f"{type(hubitat_component)}; " | ||
"must be instance of HubitatComponentGt. " | ||
f"Hubitat component id: {self.hubitat.ComponentId}" | ||
) | ||
hubitat_settings = HubitatRESTResolutionSettings(hubitat_component) | ||
devices = [ | ||
FibaroTempSensorSettings.create( | ||
tank_name=tank_node_name, | ||
settings_gt=device_gt, | ||
hubitat=hubitat_settings, | ||
node_name_format=node_name_format, | ||
) | ||
for device_gt in self.devices_gt | ||
] | ||
for device in devices: | ||
if device.node_name not in nodes: | ||
raise ValueError( | ||
f"ERROR. Node not found for tank temp sensor <{device.node_name}>" | ||
) | ||
# replace proxy hubitat component, which only had component id. | ||
# with the actual hubitat component containing data. | ||
self.hubitat = hubitat_component | ||
self.devices = devices |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.