Skip to content

Commit

Permalink
Introduces the middleware parameter to handle home-assistant-ecosystem#5
Browse files Browse the repository at this point in the history
  • Loading branch information
SeraphimSerapis committed Jan 11, 2021
1 parent 0b978b1 commit 63b2da2
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions volkszaehler/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

_LOGGER = logging.getLogger(__name__)
_RESOURCE = "{schema}://{host}:{port}/middleware.php/data/{uuid}.json"
_RESOURCE_NO_MIDDLEWARE = "{schema}://{host}:{port}/data/{uuid}.json"
_RESOURCE_FROM = "from={param_from}"
_RESOURCE_TO = "to={param_to}"

Expand All @@ -26,14 +27,21 @@ def __init__(
tls=False,
param_from="",
param_to="",
middleware=True,
):
"""Initialize the connection to the API."""
self._loop = loop
self._session = session
if tls:
self.url = _RESOURCE.format(schema="https", host=host, port=port, uuid=uuid)

if middleware:
self.url = _RESOURCE.format(
schema="https" if tls else "http", host=host, port=port, uuid=uuid
)
else:
self.url = _RESOURCE.format(schema="http", host=host, port=port, uuid=uuid)
self.url = _RESOURCE_NO_MIDDLEWARE.format(
schema="https" if tls else "http", host=host, port=port, uuid=uuid
)

self.data = {}
self.average = self.max = self.min = self.consumption = None
self.tuples = []
Expand Down

0 comments on commit 63b2da2

Please sign in to comment.