Skip to content

Commit fe05b13

Browse files
committed
add refresh status button for spino, request report status on setup, change suggested area
1 parent 41a98a3 commit fe05b13

18 files changed

Lines changed: 84 additions & 24 deletions

File tree

custom_components/mammotion/button.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ class MammotionSpinoButtonEntityDescription(ButtonEntityDescription):
5959
entity_category=EntityCategory.CONFIG,
6060
press_fn=lambda coordinator: coordinator.async_fetch_pool_line(),
6161
),
62+
MammotionSpinoButtonEntityDescription(
63+
key="spino_refresh_status",
64+
entity_category=EntityCategory.DIAGNOSTIC,
65+
press_fn=lambda coordinator: coordinator.async_request_status(),
66+
),
6267
)
6368

6469

custom_components/mammotion/coordinator.py

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2237,19 +2237,31 @@ async def _async_setup(self) -> None:
22372237
pushed to entities via the inherited ``_on_state_changed`` callback.
22382238
"""
22392239
await super()._async_setup()
2240-
for toggle in SpinoToggle:
2240+
# Start the status report stream so the device pushes dev_statue_t
2241+
# (sys_status / work_mode / battery) — the pool cleaner doesn't report
2242+
# unsolicited otherwise. See get_report_cfg_spino / async_subscribe_status.
2243+
2244+
try:
22412245
with contextlib.suppress(
2242-
DeviceOfflineException,
22432246
GatewayTimeoutException,
22442247
NoTransportAvailableError,
2248+
HomeAssistantError,
22452249
):
2246-
await self.async_send_and_wait(
2247-
"read_write_device",
2248-
"bidire_comm_cmd",
2249-
rw_id=int(toggle),
2250-
context=0,
2251-
rw=0,
2252-
)
2250+
await self.async_subscribe_status()
2251+
for toggle in SpinoToggle:
2252+
with contextlib.suppress(
2253+
GatewayTimeoutException,
2254+
NoTransportAvailableError,
2255+
):
2256+
await self.async_send_and_wait(
2257+
"read_write_device",
2258+
"bidire_comm_cmd",
2259+
rw_id=int(toggle),
2260+
context=0,
2261+
rw=0,
2262+
)
2263+
except DeviceOfflineException:
2264+
self.device.online = False
22532265

22542266
async def get_coordinator_data(
22552267
self, device: PoolCleanerDevice
@@ -2327,6 +2339,18 @@ async def update_firmware(self, version: str) -> None:
23272339

23282340
# === Pool cleaner control helpers (called by control entities) ===
23292341

2342+
async def async_subscribe_status(self) -> None:
2343+
"""Start the Spino status report stream (called once at setup).
2344+
2345+
Subscribes to RIT_CONNECT + RIT_DEV_STA with count=0 (continuous) so the
2346+
device pushes dev_statue_t frames; PoolStateReducer applies them.
2347+
"""
2348+
await self.async_send_command("get_report_cfg_spino", count=0)
2349+
2350+
async def async_request_status(self) -> None:
2351+
"""One-shot Spino status poll, backing the refresh-status button."""
2352+
await self.async_send_command("get_report_cfg_spino", count=1)
2353+
23302354
async def async_set_work_mode(self, work_mode: int) -> None:
23312355
"""Set the Spino cleaning work mode."""
23322356
await self.async_send_command("set_swimming_work_mode", work_mode=work_mode)

custom_components/mammotion/entity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ def device_info(self) -> DeviceInfo:
231231
model=spino_device.name,
232232
model_id=self.coordinator.device.product_key,
233233
sw_version=spino_device.device_firmwares.device_version,
234-
suggested_area="Garden",
234+
suggested_area="Pool",
235235
)
236236

237237
@property
Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"domain": "mammotion",
33
"name": "Mammotion",
4-
"version": "0.5.48-beta15",
4+
"version": "0.5.48",
55
"issue_tracker": "https://github.com/mikey0000/Mammotion-HA/issues",
66
"integration_type": "device",
77
"bluetooth": [
@@ -16,19 +16,11 @@
1616
"connectable": true
1717
}
1818
],
19-
"codeowners": [
20-
"@mikey0000"
21-
],
19+
"codeowners": ["@mikey0000"],
2220
"config_flow": true,
23-
"dependencies": [
24-
"bluetooth_adapters"
25-
],
21+
"dependencies": ["bluetooth_adapters"],
2622
"documentation": "https://github.com/mikey0000/Mammotion-HA/wiki",
27-
"loggers": [
28-
"pymammotion"
29-
],
23+
"loggers": ["pymammotion"],
3024
"iot_class": "local_push",
31-
"requirements": [
32-
"pymammotion==0.7.129"
33-
]
25+
"requirements": ["pymammotion==0.7.129"]
3426
}

custom_components/mammotion/strings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,9 @@
243243
},
244244
"spino_fetch_line": {
245245
"name": "Fetch cleaning route"
246+
},
247+
"spino_refresh_status": {
248+
"name": "Refresh status"
246249
}
247250
},
248251
"switch": {

custom_components/mammotion/translations/cs.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,9 @@
313313
},
314314
"restart_mower": {
315315
"name": "Restartovat sekačku"
316+
},
317+
"spino_refresh_status": {
318+
"name": "Obnovit stav"
316319
}
317320
},
318321
"switch": {

custom_components/mammotion/translations/da.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,9 @@
313313
},
314314
"restart_mower": {
315315
"name": "Genstart plæneklipperen"
316+
},
317+
"spino_refresh_status": {
318+
"name": "Opdater status"
316319
}
317320
},
318321
"switch": {

custom_components/mammotion/translations/de.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,9 @@
313313
},
314314
"restart_mower": {
315315
"name": "Mähroboter neustarten"
316+
},
317+
"spino_refresh_status": {
318+
"name": "Status aktualisieren"
316319
}
317320
},
318321
"switch": {

custom_components/mammotion/translations/en.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,9 @@
322322
},
323323
"spino_fetch_line": {
324324
"name": "Fetch cleaning route"
325+
},
326+
"spino_refresh_status": {
327+
"name": "Refresh status"
325328
}
326329
},
327330
"switch": {

custom_components/mammotion/translations/fr.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,9 @@
313313
},
314314
"restart_mower": {
315315
"name": "Redémarrer la tondeuse"
316+
},
317+
"spino_refresh_status": {
318+
"name": "Actualiser le statut"
316319
}
317320
},
318321
"switch": {

0 commit comments

Comments
 (0)