fyta-cli 0.3.2__tar.gz → 0.3.4__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.
- {fyta_cli-0.3.2 → fyta_cli-0.3.4}/PKG-INFO +3 -6
- {fyta_cli-0.3.2 → fyta_cli-0.3.4}/pyproject.toml +2 -5
- {fyta_cli-0.3.2 → fyta_cli-0.3.4}/src/fyta_cli/fyta_client.py +2 -0
- {fyta_cli-0.3.2 → fyta_cli-0.3.4}/src/fyta_cli/fyta_connector.py +11 -8
- {fyta_cli-0.3.2 → fyta_cli-0.3.4}/.github/workflows/pylint.yml +0 -0
- {fyta_cli-0.3.2 → fyta_cli-0.3.4}/.github/workflows/python-publish.yml +0 -0
- {fyta_cli-0.3.2 → fyta_cli-0.3.4}/.github/workflows/ruff.yml +0 -0
- {fyta_cli-0.3.2 → fyta_cli-0.3.4}/LICENSE +0 -0
- {fyta_cli-0.3.2 → fyta_cli-0.3.4}/README.md +0 -0
- {fyta_cli-0.3.2 → fyta_cli-0.3.4}/requirements.txt +0 -0
- {fyta_cli-0.3.2 → fyta_cli-0.3.4}/src/fyta_cli/__init__.py +0 -0
- {fyta_cli-0.3.2 → fyta_cli-0.3.4}/src/fyta_cli/fyta_exceptions.py +0 -0
- {fyta_cli-0.3.2 → fyta_cli-0.3.4}/src/fyta_cli/utils.py +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
2
|
Name: fyta_cli
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.4
|
|
4
4
|
Summary: Python library to access the FYTA API
|
|
5
5
|
Project-URL: Repository, https://github.com/dontinelli/fyta_cli.git
|
|
6
6
|
Project-URL: Issues, https://github.com/dontinelli/fyta_cli/issues
|
|
7
|
-
Project-URL: Changelog, https://github.com/dontinelli/
|
|
7
|
+
Project-URL: Changelog, https://github.com/dontinelli/fyta_cli/blob/master/CHANGELOG.md
|
|
8
8
|
Project-URL: FYTA homepage, https://fyta.de/
|
|
9
9
|
Project-URL: API Documentation, https://fyta-io.notion.site/FYTA-Public-API-d2f4c30306f74504924c9a40402a3afd
|
|
10
10
|
Author-email: dontinelli <73341522+dontinelli@users.noreply.github.com>
|
|
@@ -15,9 +15,6 @@ Classifier: Operating System :: OS Independent
|
|
|
15
15
|
Classifier: Programming Language :: Python :: 3
|
|
16
16
|
Requires-Python: >=3.11
|
|
17
17
|
Requires-Dist: aiohttp
|
|
18
|
-
Requires-Dist: asyncio
|
|
19
|
-
Requires-Dist: dataclasses
|
|
20
|
-
Requires-Dist: datetime
|
|
21
18
|
Description-Content-Type: text/markdown
|
|
22
19
|
|
|
23
20
|
# Fyta-Cli
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "fyta_cli"
|
|
3
|
-
version = "0.3.
|
|
3
|
+
version = "0.3.4"
|
|
4
4
|
authors = [
|
|
5
5
|
{ name="dontinelli", email="73341522+dontinelli@users.noreply.github.com" },
|
|
6
6
|
]
|
|
@@ -9,9 +9,6 @@ readme = "README.md"
|
|
|
9
9
|
requires-python = ">=3.11"
|
|
10
10
|
dependencies = [
|
|
11
11
|
"aiohttp",
|
|
12
|
-
"asyncio",
|
|
13
|
-
"dataclasses",
|
|
14
|
-
"datetime",
|
|
15
12
|
]
|
|
16
13
|
classifiers = [
|
|
17
14
|
"Programming Language :: Python :: 3",
|
|
@@ -30,6 +27,6 @@ packages = ["src/fyta_cli"]
|
|
|
30
27
|
[project.urls]
|
|
31
28
|
Repository = "https://github.com/dontinelli/fyta_cli.git"
|
|
32
29
|
Issues = "https://github.com/dontinelli/fyta_cli/issues"
|
|
33
|
-
Changelog = "https://github.com/dontinelli/
|
|
30
|
+
Changelog = "https://github.com/dontinelli/fyta_cli/blob/master/CHANGELOG.md"
|
|
34
31
|
"FYTA homepage" = "https://fyta.de/"
|
|
35
32
|
"API Documentation" = "https://fyta-io.notion.site/FYTA-Public-API-d2f4c30306f74504924c9a40402a3afd"
|
|
@@ -118,6 +118,7 @@ class Client():
|
|
|
118
118
|
|
|
119
119
|
if content_type.count("text/html") > 0:
|
|
120
120
|
text = await response.text()
|
|
121
|
+
msg = "Error occurred while fetching plant data"
|
|
121
122
|
raise FytaPlantError(
|
|
122
123
|
msg,
|
|
123
124
|
{"Content-Type": content_type, "response": text},
|
|
@@ -161,6 +162,7 @@ class Client():
|
|
|
161
162
|
|
|
162
163
|
if content_type.count("text/html") > 0:
|
|
163
164
|
text = await response.text()
|
|
165
|
+
msg = f"Error occurred while fetching plant data for plant {plant_id}"
|
|
164
166
|
raise FytaPlantError(
|
|
165
167
|
msg,
|
|
166
168
|
{"Content-Type": content_type, "response": text},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"""Connector class to manage access to FYTA API."""
|
|
2
2
|
|
|
3
|
-
from datetime import datetime
|
|
3
|
+
from datetime import datetime
|
|
4
4
|
from typing import Any
|
|
5
5
|
from zoneinfo import ZoneInfo
|
|
6
6
|
|
|
@@ -29,7 +29,8 @@ class FytaConnector:
|
|
|
29
29
|
access_token: str = "",
|
|
30
30
|
expiration: datetime | None = None,
|
|
31
31
|
tz: str = "",
|
|
32
|
-
):
|
|
32
|
+
) -> None:
|
|
33
|
+
"""Initialize connector class."""
|
|
33
34
|
self.email: str = email
|
|
34
35
|
self.password: str = password
|
|
35
36
|
self.client = Client(email, password, access_token, expiration)
|
|
@@ -38,7 +39,7 @@ class FytaConnector:
|
|
|
38
39
|
self.plants: dict[int, dict[str, Any]] = {}
|
|
39
40
|
self.access_token: str = access_token
|
|
40
41
|
self.expiration: datetime | None = expiration
|
|
41
|
-
self.timezone: ZoneInfo =
|
|
42
|
+
self.timezone: ZoneInfo = datetime.UTC if tz == "" else ZoneInfo(tz)
|
|
42
43
|
|
|
43
44
|
async def test_connection(self) -> bool:
|
|
44
45
|
"""Test if connection to FYTA API works."""
|
|
@@ -69,7 +70,7 @@ class FytaConnector:
|
|
|
69
70
|
|
|
70
71
|
plant_list = await self.update_plant_list()
|
|
71
72
|
|
|
72
|
-
for plant in plant_list
|
|
73
|
+
for plant in plant_list:
|
|
73
74
|
current_plant = await self.update_plant_data(plant)
|
|
74
75
|
if current_plant != {}:
|
|
75
76
|
plants |= {plant: current_plant}
|
|
@@ -82,13 +83,13 @@ class FytaConnector:
|
|
|
82
83
|
"""Get data of specific plant."""
|
|
83
84
|
|
|
84
85
|
p: dict = await self.client.get_plant_data(plant_id)
|
|
85
|
-
plant_data: dict = p["plant"]
|
|
86
86
|
|
|
87
87
|
current_plant = {}
|
|
88
88
|
|
|
89
|
-
if
|
|
89
|
+
if ("plant" not in p) or (p["plant"]["sensor"] is None):
|
|
90
90
|
current_plant |= {"sensor_available": False}
|
|
91
91
|
else:
|
|
92
|
+
plant_data: dict = p["plant"]
|
|
92
93
|
current_plant |= {"online": True}
|
|
93
94
|
current_plant |= {"sensor_available": True}
|
|
94
95
|
current_plant |= {
|
|
@@ -98,6 +99,8 @@ class FytaConnector:
|
|
|
98
99
|
current_plant |= {"name": safe_get(plant_data, "nickname", str)}
|
|
99
100
|
current_plant |= {"scientific_name": safe_get(plant_data, "scientific_name", str)}
|
|
100
101
|
current_plant |= {"status": safe_get(plant_data, "status", int)}
|
|
102
|
+
current_plant |= {"plant_thumb_path": safe_get(plant_data, "plant_thumb_path", str)}
|
|
103
|
+
current_plant |= {"plant_origin_path": safe_get(plant_data, "plant_origin_path", str)}
|
|
101
104
|
current_plant |= {
|
|
102
105
|
"temperature_status": safe_get(plant_data, "measurements.temperature.status", int)}
|
|
103
106
|
current_plant |= {
|
|
@@ -127,10 +130,10 @@ class FytaConnector:
|
|
|
127
130
|
|
|
128
131
|
@property
|
|
129
132
|
def fyta_id(self) -> str:
|
|
130
|
-
"""ID for FYTA object"""
|
|
133
|
+
"""ID for FYTA object."""
|
|
131
134
|
return self.email
|
|
132
135
|
|
|
133
136
|
@property
|
|
134
137
|
def data(self) -> dict:
|
|
135
|
-
"""ID for FYTA object"""
|
|
138
|
+
"""ID for FYTA object."""
|
|
136
139
|
return self.plants
|
|
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
|