espark-core 0.4.7__py3-none-any.whl → 0.4.8__py3-none-any.whl

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.

Potentially problematic release.


This version of espark-core might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: espark-core
3
- Version: 0.4.7
3
+ Version: 0.4.8
4
4
  Summary: The core module of the Espark ESP32-based IoT device management framework.
5
5
  License: MIT
6
6
  Requires-Python: >=3.8
@@ -10,6 +10,7 @@ Requires-Dist: aiomqtt>=2.4.0
10
10
  Requires-Dist: apscheduler>=3.11.1
11
11
  Requires-Dist: fastapi>=0.124.2
12
12
  Requires-Dist: packaging>=25.0
13
+ Requires-Dist: slack-sdk==3.39.0
13
14
  Requires-Dist: sqlalchemy>=2.0.45
14
15
  Requires-Dist: sqlmodel>=0.0.27
15
16
  Requires-Dist: uvicorn[standard]>=0.38.0
@@ -1,4 +1,4 @@
1
- espark_core-0.4.7.dist-info/licenses/LICENSE,sha256=wkIXJHYIspOGVvn_ajKyLucpIyw9_pO3QExFcNTCY78,1065
1
+ espark_core-0.4.8.dist-info/licenses/LICENSE,sha256=wkIXJHYIspOGVvn_ajKyLucpIyw9_pO3QExFcNTCY78,1065
2
2
  esparkcore/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  esparkcore/constants.py,sha256=uI0bVa78CZa-ftlyTRMqWSBK275iDB1l8g1TmtJ1FGg,378
4
4
  esparkcore/data/__init__.py,sha256=abMOPq6jC5qOQCl9j7iPDv8iyjzDF-oVd_gW0la5kL4,45
@@ -14,19 +14,22 @@ esparkcore/data/repositories/device_repository.py,sha256=P9KK-Ta9MgMdrnct5hbGEoi
14
14
  esparkcore/data/repositories/outbox_repository.py,sha256=PdPyKq2Km4_7732O6HhA4BlV_zBjYF91GkMltNKUovg,1015
15
15
  esparkcore/data/repositories/telemetry_repository.py,sha256=5UBBmY-ugcgP0Xji7cu58_nGt8MWKeHz9DHNVJxk0BY,1116
16
16
  esparkcore/data/repositories/version_repository.py,sha256=QZZX2BpFx1i0oeFJ6j0nZvlZH7cViKU8VERBE8AU3ZY,395
17
+ esparkcore/notifications/__init__.py,sha256=WrdUPsRS0tg2rAhv4aj4eGDekkfAsKjcRPRlT6btzQs,77
18
+ esparkcore/notifications/notifier.py,sha256=N59O8K4jbpIMOMwSPRrZ-sbnN82ynxx6qelCDKV1E_4,456
19
+ esparkcore/notifications/slack_notifier.py,sha256=D3adrI1sFMtQpIQEtVRILZecIVCUA7sDcgtDzm9w6Fg,592
17
20
  esparkcore/routers/__init__.py,sha256=K8-S0hugkQT5DB8i8O5YqeRsu9fGfLep6UQzCIpdgGg,131
18
21
  esparkcore/routers/base_router.py,sha256=t-x8tYZVzBk9bD__9yaGYhm66glq_oM_lAHn0eplM2M,3902
19
22
  esparkcore/routers/device_router.py,sha256=mIBAyTyxl9AF8Os_Sms6Bb0vEvWfljyElbTWEGLo0iU,1172
20
23
  esparkcore/routers/telemetry_router.py,sha256=sLO5-oN73IjdGC_ASNif5xmVZHjka_iLv0BKZ_deZP0,1981
21
- esparkcore/routers/version_router.py,sha256=zoOteeK4Cs-OIk_k2v7vPwpR-OfLBwYhOUhNZjPYfHs,387
24
+ esparkcore/routers/version_router.py,sha256=7HYD6sbGWow3DDvK62RXPZu5Qz8DCTTs7wkksQKBq9c,383
22
25
  esparkcore/schedules/__init__.py,sha256=v5Wy3Cbt2AnudGMGXv_Cyaa10s6NAmP66rDjcMSvf0o,74
23
26
  esparkcore/schedules/outbox.py,sha256=GGANvjkI7w1BdmmVRgKog498ASD_xRN0g8bG6yC_SN4,811
24
27
  esparkcore/schedules/scheduler.py,sha256=aYQXImLZ4tW-hRavn3ObuV3lYjmOZD813YkeG1NsYfY,170
25
28
  esparkcore/services/__init__.py,sha256=RIZOHBfkWn3HsApdA5rH9EZbbXGq0NfiGoOWDO_JX1k,30
26
- esparkcore/services/mqtt.py,sha256=Ey2pEkG8sTgX7MQqX1z3Y_5ATwBnacJuf18F_u59_lg,6575
29
+ esparkcore/services/mqtt.py,sha256=EFRVT7QYEpWFhTopS2T6J5O69NWbxeuBQnytCjvd23k,6379
27
30
  esparkcore/utils/__init__.py,sha256=rzuCJUAaQl-yPhM1vcWB_1zVXqtA71ChYP2aM_3UfKk,42
28
31
  esparkcore/utils/logging.py,sha256=sRO8uOcPkFH-DwepqLOTS2qGaopXpMdVOjzZL6RpGs4,257
29
- espark_core-0.4.7.dist-info/METADATA,sha256=faFvfPL1qF0ika4MKD-VbLFL8ZTis3XAmk5zHr7HQeE,6296
30
- espark_core-0.4.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
31
- espark_core-0.4.7.dist-info/top_level.txt,sha256=hXVyhIPB4aGskFm5queWALxDPhcDkrN7_8vcjwA1iE4,11
32
- espark_core-0.4.7.dist-info/RECORD,,
32
+ espark_core-0.4.8.dist-info/METADATA,sha256=w89JMtUB_nVoQKipy_DqXK5tdof6lSwY7pgdwMtBiK0,6329
33
+ espark_core-0.4.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
34
+ espark_core-0.4.8.dist-info/top_level.txt,sha256=hXVyhIPB4aGskFm5queWALxDPhcDkrN7_8vcjwA1iE4,11
35
+ espark_core-0.4.8.dist-info/RECORD,,
@@ -0,0 +1,2 @@
1
+ from .notifier import BaseNotifier
2
+ from .slack_notifier import SlackNotifier
@@ -0,0 +1,14 @@
1
+ from abc import ABC, abstractmethod
2
+
3
+
4
+ class BaseNotifier(ABC):
5
+ @abstractmethod
6
+ async def notify(self, device_id: str, event_type: str, value: int, **kwargs) -> None:
7
+ """
8
+ Send a notification for an event.
9
+
10
+ Args:
11
+ device_id: ID of the device generating the event.
12
+ event_type: Type of the event (human presence, door open, etc).
13
+ value: An integer value associated with the event.
14
+ """
@@ -0,0 +1,16 @@
1
+ from slack_sdk import WebClient
2
+
3
+ from ..utils import log_debug
4
+ from .notifier import BaseNotifier
5
+
6
+
7
+ class SlackNotifier(BaseNotifier):
8
+ async def notify(self, device_id: str, event_type: str, value: int, **kwargs) -> None:
9
+ slack_token = kwargs.get('slack_token')
10
+ slack_channel = kwargs.get('slack_channel')
11
+
12
+ client = WebClient(token=slack_token)
13
+
14
+ log_debug(f'Posting {event_type} event to Slack for device {device_id}: {value}')
15
+
16
+ client.chat_postMessage(channel=slack_channel, text=f'Device {device_id} reported {event_type} with value {value}.')
@@ -7,4 +7,4 @@ class AppVersionRouter(BaseRouter):
7
7
  def __init__(self, repo: AppVersionRepository = None) -> None:
8
8
  self.repo : AppVersionRepository = repo or AppVersionRepository()
9
9
 
10
- super().__init__(AppVersion, self.repo, '/api/v1/versions', ['version'])
10
+ super().__init__(AppVersion, self.repo, '/api/v1/apps', ['version'])
@@ -32,10 +32,7 @@ class MQTTManager:
32
32
  async with async_session() as session:
33
33
  device = await self.device_repo.get(session, Device.id == device_id)
34
34
  if device:
35
- device.app_name = payload['app_name']
36
- device.app_version = payload['app_version']
37
- device.capabilities = payload['capabilities']
38
- device.last_seen = datetime.now(timezone.utc)
35
+ device.last_seen = datetime.now(timezone.utc)
39
36
 
40
37
  await self.device_repo.update(session, device, last_seen=datetime.now(timezone.utc))
41
38
  else: