Skip to content

Commit

Permalink
Bump versions and reconnect fix
Browse files Browse the repository at this point in the history
Signed-off-by: Johannes Ott <[email protected]>
  • Loading branch information
DerOetzi committed Jun 24, 2024
1 parent 50f5785 commit 3562c4a
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ jobs:
${{ env.REGISTRY_GITHUB }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6
with:
builder: ${{ steps.buildx.outputs.name }}
context: .
Expand Down
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ ephem==4.1.5
influxdb-client==1.43.0
jsonref==1.1.0
loguru==0.7.2
numpy==1.26.4
numpy==2.0.0
pandas==2.2.2
pydantic==2.7.1
pydantic==2.7.4
pyjwt==2.8.0
requests==2.32.2
requests==2.32.3
scikit-learn==1.4.2
scipy==1.13.1
solaredge_modbus==0.8.0
Expand Down
4 changes: 2 additions & 2 deletions solaredge2mqtt/core/events/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import asyncio
from typing import Callable

from aiomqtt import MqttError
from aiomqtt import MqttCodeError

from solaredge2mqtt.core.exceptions import InvalidDataException
from solaredge2mqtt.core.logging import logger
Expand Down Expand Up @@ -71,7 +71,7 @@ async def _notify_listeners(
await asyncio.gather(
*[self._notify_listener(listener, event) for listener in listeners]
)
except MqttError as error:
except MqttCodeError as error:
raise error
except asyncio.CancelledError:
pass
Expand Down
4 changes: 1 addition & 3 deletions solaredge2mqtt/core/mqtt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,8 @@ def __init__(self, settings: MQTTSettings, event_bus: EventBus):
super().__init__(
self.broker,
self.port,
username=settings.username,
password=settings.password.get_secret_value(),
identifier=settings.client_id,
will=will,
**settings.kargs,
)

def _subscribe_events(self) -> None:
Expand Down
15 changes: 13 additions & 2 deletions solaredge2mqtt/core/mqtt/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ class MQTTSettings(BaseModel):
client_id: str = Field("solaredge2mqtt")
broker: str
port: int = Field(1883)
username: str
password: SecretStr
username: str | None = Field(None)
password: SecretStr | None = Field(None)
topic_prefix: str = Field("solaredge")

@property
def kargs(self) -> dict[str, str]:
args = {"identifier": self.client_id}

if self.username is not None:
args["username"] = self.username
if self.password is not None:
args["password"] = self.password.get_secret_value()

return args

0 comments on commit 3562c4a

Please sign in to comment.