diff --git a/volkszaehler/__init__.py b/volkszaehler/__init__.py index ba86079..1511e9e 100644 --- a/volkszaehler/__init__.py +++ b/volkszaehler/__init__.py @@ -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}" @@ -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 = []