fyta-cli 0.3.3__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.
@@ -1,10 +1,10 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: fyta_cli
3
- Version: 0.3.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/fyta_cly/blob/master/CHANGELOG.md
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>
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "fyta_cli"
3
- version = "0.3.3"
3
+ version = "0.3.4"
4
4
  authors = [
5
5
  { name="dontinelli", email="73341522+dontinelli@users.noreply.github.com" },
6
6
  ]
@@ -27,6 +27,6 @@ packages = ["src/fyta_cli"]
27
27
  [project.urls]
28
28
  Repository = "https://github.com/dontinelli/fyta_cli.git"
29
29
  Issues = "https://github.com/dontinelli/fyta_cli/issues"
30
- Changelog = "https://github.com/dontinelli/fyta_cly/blob/master/CHANGELOG.md"
30
+ Changelog = "https://github.com/dontinelli/fyta_cli/blob/master/CHANGELOG.md"
31
31
  "FYTA homepage" = "https://fyta.de/"
32
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, timezone
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 = timezone.utc if tz == "" else ZoneInfo(tz)
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.keys():
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 plant_data["sensor"] is None:
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 |= {
@@ -129,10 +130,10 @@ class FytaConnector:
129
130
 
130
131
  @property
131
132
  def fyta_id(self) -> str:
132
- """ID for FYTA object"""
133
+ """ID for FYTA object."""
133
134
  return self.email
134
135
 
135
136
  @property
136
137
  def data(self) -> dict:
137
- """ID for FYTA object"""
138
+ """ID for FYTA object."""
138
139
  return self.plants
File without changes
File without changes
File without changes
File without changes