pyemoncms 0.1.1__tar.gz → 0.1.3__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,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: pyemoncms
3
- Version: 0.1.1
3
+ Version: 0.1.3
4
4
  Summary: A python library to interrogate emoncms API
5
5
  Home-page: https://github.com/Open-Building-Management/pyemoncms
6
6
  Author: Alexandre CUER
@@ -13,6 +13,17 @@ Requires-Python: >=3.9
13
13
  Description-Content-Type: text/markdown
14
14
  License-File: LICENSE
15
15
  Requires-Dist: aiohttp
16
+ Dynamic: author
17
+ Dynamic: author-email
18
+ Dynamic: classifier
19
+ Dynamic: description
20
+ Dynamic: description-content-type
21
+ Dynamic: home-page
22
+ Dynamic: license-file
23
+ Dynamic: project-url
24
+ Dynamic: requires-dist
25
+ Dynamic: requires-python
26
+ Dynamic: summary
16
27
 
17
28
  # pyemoncms
18
29
  python library for emoncms API
@@ -14,8 +14,9 @@ so there is a type error if you search for a key in the response
14
14
 
15
15
  import asyncio
16
16
  from dataclasses import dataclass
17
+ import json
17
18
  import logging
18
- from typing import Any, TypeVar
19
+ from typing import Any, Dict, TypeVar, Optional
19
20
 
20
21
  from aiohttp import ClientError, ClientSession
21
22
 
@@ -84,6 +85,37 @@ class EmoncmsClient:
84
85
  self.logger.error(message)
85
86
  return data
86
87
 
88
+ async def async_input_post(
89
+ self,
90
+ data: Dict[str, Any],
91
+ node: Optional[str] = None,
92
+ time: Optional[int] = None,
93
+ apikey: Optional[str] = None,
94
+ ) -> bool:
95
+ """Async post data to an emoncms input/node."""
96
+ if self.session is None:
97
+ self.session = ClientSession()
98
+ self._close_session = True
99
+
100
+ endpoint = f"{self.url.rstrip('/')}/input/post"
101
+ json_string = json.dumps(data)
102
+
103
+ effective_key = apikey if apikey is not None else self.api_key
104
+ if not effective_key:
105
+ raise ValueError("API key must be provided.")
106
+
107
+ params = {"apikey": effective_key, "fulljson": json_string}
108
+ if node:
109
+ params["node"] = node
110
+ if time is not None:
111
+ params["time"] = str(time)
112
+
113
+ async with self.session.post(endpoint, params=params) as resp:
114
+ text = await resp.text()
115
+ if resp.status != 200:
116
+ raise RuntimeError(f"POST failed ({resp.status}): {text}")
117
+ return True
118
+
87
119
  async def async_get_uuid(self) -> str | None:
88
120
  """Return the unique identifier or None.
89
121
 
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: pyemoncms
3
- Version: 0.1.1
3
+ Version: 0.1.3
4
4
  Summary: A python library to interrogate emoncms API
5
5
  Home-page: https://github.com/Open-Building-Management/pyemoncms
6
6
  Author: Alexandre CUER
@@ -13,6 +13,17 @@ Requires-Python: >=3.9
13
13
  Description-Content-Type: text/markdown
14
14
  License-File: LICENSE
15
15
  Requires-Dist: aiohttp
16
+ Dynamic: author
17
+ Dynamic: author-email
18
+ Dynamic: classifier
19
+ Dynamic: description
20
+ Dynamic: description-content-type
21
+ Dynamic: home-page
22
+ Dynamic: license-file
23
+ Dynamic: project-url
24
+ Dynamic: requires-dist
25
+ Dynamic: requires-python
26
+ Dynamic: summary
16
27
 
17
28
  # pyemoncms
18
29
  python library for emoncms API
@@ -6,7 +6,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
6
6
 
7
7
  setuptools.setup(
8
8
  name="pyemoncms",
9
- version="0.1.1",
9
+ version="0.1.3",
10
10
  author="Alexandre CUER",
11
11
  author_email="alexandre.cuer@wanadoo.fr",
12
12
  description="A python library to interrogate emoncms API",
File without changes
File without changes
File without changes
File without changes