HomeAssistant-API 4.0.0.post2__tar.gz → 4.0.1__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.
Files changed (21) hide show
  1. {HomeAssistant-API-4.0.0.post2 → homeassistant_api-4.0.1}/LICENSE +0 -53
  2. {HomeAssistant-API-4.0.0.post2 → homeassistant_api-4.0.1}/PKG-INFO +5 -4
  3. {HomeAssistant-API-4.0.0.post2 → homeassistant_api-4.0.1}/homeassistant_api/client.py +10 -13
  4. {HomeAssistant-API-4.0.0.post2 → homeassistant_api-4.0.1}/homeassistant_api/models/states.py +4 -1
  5. {HomeAssistant-API-4.0.0.post2 → homeassistant_api-4.0.1}/homeassistant_api/rawasyncclient.py +3 -3
  6. {HomeAssistant-API-4.0.0.post2 → homeassistant_api-4.0.1}/homeassistant_api/rawclient.py +4 -4
  7. {HomeAssistant-API-4.0.0.post2 → homeassistant_api-4.0.1}/pyproject.toml +12 -7
  8. {HomeAssistant-API-4.0.0.post2 → homeassistant_api-4.0.1}/setup.py +5 -5
  9. {HomeAssistant-API-4.0.0.post2 → homeassistant_api-4.0.1}/README.md +0 -0
  10. {HomeAssistant-API-4.0.0.post2 → homeassistant_api-4.0.1}/homeassistant_api/__init__.py +0 -0
  11. {HomeAssistant-API-4.0.0.post2 → homeassistant_api-4.0.1}/homeassistant_api/errors.py +0 -0
  12. {HomeAssistant-API-4.0.0.post2 → homeassistant_api-4.0.1}/homeassistant_api/models/__init__.py +0 -0
  13. {HomeAssistant-API-4.0.0.post2 → homeassistant_api-4.0.1}/homeassistant_api/models/base.py +0 -0
  14. {HomeAssistant-API-4.0.0.post2 → homeassistant_api-4.0.1}/homeassistant_api/models/domains.py +0 -0
  15. {HomeAssistant-API-4.0.0.post2 → homeassistant_api-4.0.1}/homeassistant_api/models/entity.py +0 -0
  16. {HomeAssistant-API-4.0.0.post2 → homeassistant_api-4.0.1}/homeassistant_api/models/events.py +0 -0
  17. {HomeAssistant-API-4.0.0.post2 → homeassistant_api-4.0.1}/homeassistant_api/models/history.py +0 -0
  18. {HomeAssistant-API-4.0.0.post2 → homeassistant_api-4.0.1}/homeassistant_api/models/logbook.py +0 -0
  19. {HomeAssistant-API-4.0.0.post2 → homeassistant_api-4.0.1}/homeassistant_api/processing.py +0 -0
  20. {HomeAssistant-API-4.0.0.post2 → homeassistant_api-4.0.1}/homeassistant_api/py.typed +0 -0
  21. {HomeAssistant-API-4.0.0.post2 → homeassistant_api-4.0.1}/homeassistant_api/rawbaseclient.py +0 -0
@@ -619,56 +619,3 @@ Program, unless a warranty or assumption of liability accompanies a
619
619
  copy of the Program in return for a fee.
620
620
 
621
621
  END OF TERMS AND CONDITIONS
622
-
623
- How to Apply These Terms to Your New Programs
624
-
625
- If you develop a new program, and you want it to be of the greatest
626
- possible use to the public, the best way to achieve this is to make it
627
- free software which everyone can redistribute and change under these terms.
628
-
629
- To do so, attach the following notices to the program. It is safest
630
- to attach them to the start of each source file to most effectively
631
- state the exclusion of warranty; and each file should have at least
632
- the "copyright" line and a pointer to where the full notice is found.
633
-
634
- <one line to give the program's name and a brief idea of what it does.>
635
- Copyright (C) <year> <name of author>
636
-
637
- This program is free software: you can redistribute it and/or modify
638
- it under the terms of the GNU General Public License as published by
639
- the Free Software Foundation, either version 3 of the License, or
640
- (at your option) any later version.
641
-
642
- This program is distributed in the hope that it will be useful,
643
- but WITHOUT ANY WARRANTY; without even the implied warranty of
644
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645
- GNU General Public License for more details.
646
-
647
- You should have received a copy of the GNU General Public License
648
- along with this program. If not, see <https://www.gnu.org/licenses/>.
649
-
650
- Also add information on how to contact you by electronic and paper mail.
651
-
652
- If the program does terminal interaction, make it output a short
653
- notice like this when it starts in an interactive mode:
654
-
655
- <program> Copyright (C) <year> <name of author>
656
- This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657
- This is free software, and you are welcome to redistribute it
658
- under certain conditions; type `show c' for details.
659
-
660
- The hypothetical commands `show w' and `show c' should show the appropriate
661
- parts of the General Public License. Of course, your program's commands
662
- might be different; for a GUI interface, you would use an "about box".
663
-
664
- You should also get your employer (if you work as a programmer) or school,
665
- if any, to sign a "copyright disclaimer" for the program, if necessary.
666
- For more information on this, and how to apply and follow the GNU GPL, see
667
- <https://www.gnu.org/licenses/>.
668
-
669
- The GNU General Public License does not permit incorporating your program
670
- into proprietary programs. If your program is a subroutine library, you
671
- may consider it more useful to permit linking proprietary applications with
672
- the library. If this is what you want to do, use the GNU Lesser General
673
- Public License instead of this License. But first, please read
674
- <https://www.gnu.org/licenses/why-not-lgpl.html>.
@@ -1,22 +1,23 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: homeassistant-api
3
- Version: 4.0.0.post2
3
+ Version: 4.0.1
4
4
  Summary: Python Wrapper for Homeassistant's REST API
5
5
  Home-page: https://github.com/GrandMoff100/HomeAssistantAPI
6
6
  License: GPL-3.0-or-later
7
7
  Author: GrandMoff100
8
8
  Author-email: minecraftcrusher100@gmail.com
9
- Requires-Python: >=3.7,<4.0.0
9
+ Requires-Python: >=3.7,<4.0
10
10
  Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
11
11
  Classifier: Programming Language :: Python :: 3
12
- Classifier: Programming Language :: Python :: 3.10
13
12
  Classifier: Programming Language :: Python :: 3.7
14
13
  Classifier: Programming Language :: Python :: 3.8
15
14
  Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
16
17
  Requires-Dist: aiohttp (>=3.8.1,<4.0.0)
17
18
  Requires-Dist: aiohttp-client-cache (>=0.6.1,<0.7.0)
18
19
  Requires-Dist: pydantic (<=1.9.0)
19
- Requires-Dist: requests (==2.27.1)
20
+ Requires-Dist: requests (>=2.27.1,<3.0.0)
20
21
  Requires-Dist: requests-cache (>=0.9.2,<0.10.0)
21
22
  Requires-Dist: simplejson (>=3.17.6,<4.0.0)
22
23
  Project-URL: Documentation, https://homeassistantapi.readthedocs.io
@@ -1,11 +1,12 @@
1
1
  """Module containing the primary Client class."""
2
- import gc
3
- import inspect
2
+ import logging
4
3
  from typing import Any
5
4
 
6
5
  from .rawasyncclient import RawAsyncClient
7
6
  from .rawclient import RawClient
8
7
 
8
+ logger = logging.getLogger(__name__)
9
+
9
10
 
10
11
  class Client(RawClient, RawAsyncClient):
11
12
  """
@@ -18,14 +19,10 @@ class Client(RawClient, RawAsyncClient):
18
19
  :param async_cache_session: A :py:class:`aiohttp_client_cache.CachedSession` object to use for caching requests. Optional.
19
20
  """ # pylint: disable=line-too-long
20
21
 
21
- def __init__(self, *args: Any, **kwargs: Any) -> None:
22
- assert (frame := inspect.currentframe()) is not None
23
- assert (parent_frame := frame.f_back) is not None
24
- try:
25
- if inspect.iscoroutinefunction(
26
- caller := gc.get_referrers(parent_frame.f_code)[0]
27
- ) or inspect.iscoroutine(caller):
28
- RawAsyncClient.__init__(self, *args, **kwargs)
29
- except IndexError: # pragma: no cover
30
- pass
31
- RawClient.__init__(self, *args, **kwargs)
22
+ def __init__(self, *args: Any, use_async: bool = False, **kwargs: Any) -> None:
23
+ if use_async:
24
+ logger.error("Initializing Client asyncsyncronously")
25
+ RawAsyncClient.__init__(self, *args, **kwargs)
26
+ else:
27
+ logger.error("Initializing Client syncronously")
28
+ RawClient.__init__(self, *args, **kwargs)
@@ -10,7 +10,10 @@ from .base import BaseModel
10
10
  class Context(BaseModel):
11
11
  """Model for entity state contexts."""
12
12
 
13
- id: str = Field(max_length=26, description="Unique string identifying the context.")
13
+ id: str = Field(
14
+ max_length=128,
15
+ description="Unique string identifying the context.",
16
+ )
14
17
 
15
18
 
16
19
  class State(BaseModel):
@@ -56,7 +56,7 @@ class RawAsyncClient(RawBaseClient):
56
56
  ] = None, # Explicitly disable cache with async_cache_session=False
57
57
  **kwargs,
58
58
  ):
59
- super().__init__(*args, **kwargs)
59
+ RawBaseClient.__init__(self, *args, **kwargs)
60
60
  if async_cache_session is False:
61
61
  self.async_cache_session = aiohttp.ClientSession()
62
62
  elif async_cache_session is None:
@@ -77,9 +77,9 @@ class RawAsyncClient(RawBaseClient):
77
77
  await self.async_check_api_running()
78
78
  return self
79
79
 
80
- async def __aexit__(self, cls, obj, traceback):
80
+ async def __aexit__(self, _, __, ___):
81
81
  logger.debug("Exiting async requests session %r", self.async_cache_session)
82
- await self.async_cache_session.__aexit__(cls, obj, traceback)
82
+ await self.async_cache_session.close()
83
83
 
84
84
  # Very important request function
85
85
  async def async_request(
@@ -36,7 +36,7 @@ logger = logging.getLogger(__name__)
36
36
 
37
37
  class RawClient(RawBaseClient):
38
38
  """
39
- The base object for interacting with Homeassistant
39
+ The base object for interacting with Homeassistant.
40
40
 
41
41
  :param api_url: The location of the api endpoint. e.g. :code:`http://localhost:8123/api` Required.
42
42
  :param token: The refresh or long lived access token to authenticate your requests. Required.
@@ -55,7 +55,7 @@ class RawClient(RawBaseClient):
55
55
  ] = None, # Explicitly disable cache with cache_session=False
56
56
  **kwargs,
57
57
  ):
58
- super().__init__(*args, **kwargs)
58
+ RawBaseClient.__init__(self, *args, **kwargs)
59
59
  if cache_session is False:
60
60
  self.cache_session = requests.Session()
61
61
  elif cache_session is None:
@@ -74,9 +74,9 @@ class RawClient(RawBaseClient):
74
74
  self.check_api_config()
75
75
  return self
76
76
 
77
- def __exit__(self, *args):
77
+ def __exit__(self, _, __, ___):
78
78
  logger.debug("Exiting requests session %r", self.cache_session)
79
- self.cache_session.__exit__(*args)
79
+ self.cache_session.close()
80
80
 
81
81
  def request(
82
82
  self,
@@ -18,18 +18,27 @@ name = "HomeAssistant-API"
18
18
  readme = "README.md"
19
19
  include = ["homeassistant_api/py.typed"]
20
20
  repository = "https://github.com/GrandMoff100/HomeAssistantAPI"
21
- version = "4.0.0.post2"
21
+ version = "4.0.1"
22
22
  packages = [{ include = "homeassistant_api" }]
23
23
 
24
24
  [tool.poetry.dependencies]
25
25
  aiohttp = "^3.8.1"
26
26
  aiohttp-client-cache = "^0.6.1"
27
27
  pydantic = "<=1.9.0"
28
- python = ">=3.7,<4.0.0"
29
- requests = "2.27.1"
28
+ python = "^3.7,<4.0.0"
29
+ requests = "^2.27.1"
30
30
  requests-cache = "^0.9.2"
31
31
  simplejson = "^3.17.6"
32
32
 
33
+ [tool.poetry.group.docs]
34
+ optional = true
35
+
36
+ [tool.poetry.group.docs.dependencies]
37
+ sphinx-autodoc-typehints = "^1.17.0"
38
+ sphinx-rtd-theme = "^1.0.0"
39
+ autodoc-pydantic = "^1.6.1"
40
+ toml = "^0.10.2"
41
+
33
42
  [tool.poetry.dev-dependencies]
34
43
  black = "^22.3.0"
35
44
  flake8 = "^4.0.1"
@@ -37,18 +46,14 @@ isort = "^5.10.1"
37
46
  pre-commit = "^2.17.0"
38
47
  pylint = "^2.12.2"
39
48
  pytest = "^6.2.5"
40
- sphinx-autodoc-typehints = {version = "^1.17.0", extras = ["docs"]}
41
- sphinx-rtd-theme = {version = "^1.0.0", extras = ["docs"]}
42
49
  toml = "^0.10.2"
43
50
  types-docutils = "^0.17.5"
44
51
  types-requests = "^2.27.9"
45
52
  types-simplejson = "^3.17.3"
46
53
  types-toml = "^0.10.4"
47
54
  mypy = "^0.931"
48
- autodoc-pydantic = {version = "^1.6.1", extras = ["docs"]}
49
55
  pytest-asyncio = "^0.18.3"
50
56
  pytest-cov = "^3.0.0"
51
- coverage = {extras = ["toml"], version = "^6.4.1"}
52
57
  aiosqlite = "^0.17.0"
53
58
 
54
59
  [tool.pylint.master]
@@ -12,23 +12,23 @@ install_requires = \
12
12
  'aiohttp>=3.8.1,<4.0.0',
13
13
  'pydantic<=1.9.0',
14
14
  'requests-cache>=0.9.2,<0.10.0',
15
- 'requests==2.27.1',
15
+ 'requests>=2.27.1,<3.0.0',
16
16
  'simplejson>=3.17.6,<4.0.0']
17
17
 
18
18
  setup_kwargs = {
19
19
  'name': 'homeassistant-api',
20
- 'version': '4.0.0.post2',
20
+ 'version': '4.0.1',
21
21
  'description': "Python Wrapper for Homeassistant's REST API",
22
22
  'long_description': '# HomeassistantAPI\n\n[![Code Coverage](https://img.shields.io/codecov/c/github/GrandMoff100/HomeAssistantAPI/dev?style=for-the-badge&token=SJFC3HX5R1)](https://codecov.io/gh/GrandMoff100/HomeAssistantAPI)\n[![PyPI - Downloads](https://img.shields.io/pypi/dm/HomeAssistant-API?style=for-the-badge)](https://pypi.org/project/homeassistant_api)\n![GitHub commits since latest release (by date including pre-releases)](https://img.shields.io/github/commits-since/GrandMoff100/HomeassistantAPI/latest/dev?include_prereleases&style=for-the-badge)\n[![Read the Docs (version)](https://img.shields.io/readthedocs/homeassistantapi?style=for-the-badge)](https://homeassistantapi.readthedocs.io/en/latest/?badge=latest)\n[![GitHub release (latest by date)](https://img.shields.io/github/v/release/GrandMoff100/HomeassistantAPI?style=for-the-badge)](https://github.com/GrandMoff100/HomeassistantAPI/releases)\n\n[![Home Assistant Logo](https://github.com/GrandMoff100/HomeAssistantAPI/blob/7edb4e6298d37bda19c08b807613c6d351788491/docs/images/homeassistant-logo.png?raw=true)](https://home-assistant.io)\n\n## Python wrapper for Homeassistant\'s [REST API](https://developers.home-assistant.io/docs/api/rest/)\n\nHere is a quick example.\n\n```py\nfrom homeassistant_api import Client\n\nwith Client(\n \'<API Server URL>\',\n \'<Your Long Lived Access-Token>\'\n) as client:\n\n light = client.get_domain("light")\n\n light.turn_on(entity_id="light.living_room_lamp")\n```\n\nAll the methods also support async!\n\n## Documentation\n\nAll documentation, API reference, contribution guidelines and pretty much everything else\nyou\'d want to know is on our readthedocs site [here](https://homeassistantapi.readthedocs.io)\n\nIf there is something missing, open an issue and let us know! Thanks!\n\nGo make some cool stuff! Maybe come back and tell us about it in a\n[discussion](https://github.com/GrandMoff100/HomeAssistantAPI/discussions)?\nWe\'d love to hear about how you use our library!!\n\n## License\n\nThis project is under the GNU GPLv3 license, as defined by the Free Software Foundation.\n',
23
23
  'author': 'GrandMoff100',
24
24
  'author_email': 'minecraftcrusher100@gmail.com',
25
- 'maintainer': None,
26
- 'maintainer_email': None,
25
+ 'maintainer': 'None',
26
+ 'maintainer_email': 'None',
27
27
  'url': 'https://github.com/GrandMoff100/HomeAssistantAPI',
28
28
  'packages': packages,
29
29
  'package_data': package_data,
30
30
  'install_requires': install_requires,
31
- 'python_requires': '>=3.7,<4.0.0',
31
+ 'python_requires': '>=3.7,<4.0',
32
32
  }
33
33
 
34
34