Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 31 additions & 16 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ requires-python = '>=3.12,<4.0'
dependencies = [
"saic-ismart-client-ng (>=0.9.2,<0.10.0)",
'httpx (>=0.28.1,<0.29.0)',
'gmqtt (>=0.7.0,<0.8.0)',
'inflection (>=0.5.1,<0.6.0)',
'apscheduler (>=3.11.0,<4.0.0)',
'python-dotenv (>=1.1.1,<2.0.0)',
"aiomqtt (>=2.4.0,<3.0.0)",
]

[project.urls]
Expand Down
7 changes: 5 additions & 2 deletions src/configuration/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
from __future__ import annotations

from enum import Enum
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Literal

if TYPE_CHECKING:
from integrations.openwb.charging_station import ChargingStation


Transport = Literal["tcp", "websockets"]


class TransportProtocol(Enum):
def __init__(self, transport_mechanism: str, with_tls: bool) -> None:
def __init__(self, transport_mechanism: Transport, with_tls: bool) -> None:
self.transport_mechanism = transport_mechanism
self.with_tls = with_tls

Expand Down
11 changes: 7 additions & 4 deletions src/configuration/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,18 @@ def __parse_mqtt_transport(args: Namespace, config: Configuration) -> None:
args.tls_server_cert_check_hostname
)
else:
msg = f"Invalid MQTT URI scheme: {parse_result.scheme}, use tcp or ws"
msg = f"Invalid MQTT URI scheme: {parse_result.scheme}, use tls, tcp or ws"
raise SystemExit(msg)

if parse_result.port:
config.mqtt_port = parse_result.port
elif config.mqtt_transport_protocol == TransportProtocol.TCP:
config.mqtt_port = 1883
else:
elif config.mqtt_transport_protocol == TransportProtocol.TLS:
config.mqtt_port = 8883
elif config.mqtt_transport_protocol == TransportProtocol.WS:
config.mqtt_port = 9001
else:
# fallback to default mqtt port
config.mqtt_port = 1883
config.mqtt_host = str(parse_result.hostname)


Expand Down
2 changes: 1 addition & 1 deletion src/log_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

MODULES_DEFAULT_LOG_LEVEL = {
"asyncio": "WARNING",
"gmqtt": "WARNING",
"aiomqtt": "WARNING",
"httpcore": "WARNING",
"httpx": "WARNING",
"saic_ismart_client_ng": "WARNING",
Expand Down
1 change: 1 addition & 0 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@
configuration = process_command_line()

mqtt_gateway = MqttGateway(configuration)

asyncio.run(mqtt_gateway.run(), debug=debug_log_enabled())
Loading