Fix Fully Kiosk Browser MQTT event callbacks with non-standard event topics (#105735)
This commit is contained in:
parent
a488d120b7
commit
40f914214b
2 changed files with 23 additions and 5 deletions
|
@ -74,7 +74,8 @@ class FullyKioskEntity(CoordinatorEntity[FullyKioskDataUpdateCoordinator], Entit
|
|||
@callback
|
||||
def message_callback(message: mqtt.ReceiveMessage) -> None:
|
||||
payload = json.loads(message.payload)
|
||||
event_callback(**payload)
|
||||
if "event" in payload and payload["event"] == event:
|
||||
event_callback(**payload)
|
||||
|
||||
topic_template = data["settings"]["mqttEventTopic"]
|
||||
topic = (
|
||||
|
@ -82,4 +83,5 @@ class FullyKioskEntity(CoordinatorEntity[FullyKioskDataUpdateCoordinator], Entit
|
|||
.replace("$event", event)
|
||||
.replace("$deviceId", data["deviceID"])
|
||||
)
|
||||
|
||||
return await mqtt.async_subscribe(self.hass, topic, message_callback)
|
||||
|
|
|
@ -107,19 +107,35 @@ async def test_switches_mqtt_update(
|
|||
assert entity
|
||||
assert entity.state == "on"
|
||||
|
||||
async_fire_mqtt_message(hass, "fully/event/onScreensaverStart/abcdef-123456", "{}")
|
||||
async_fire_mqtt_message(
|
||||
hass,
|
||||
"fully/event/onScreensaverStart/abcdef-123456",
|
||||
'{"deviceId": "abcdef-123456","event": "onScreensaverStart"}',
|
||||
)
|
||||
entity = hass.states.get("switch.amazon_fire_screensaver")
|
||||
assert entity.state == "on"
|
||||
|
||||
async_fire_mqtt_message(hass, "fully/event/onScreensaverStop/abcdef-123456", "{}")
|
||||
async_fire_mqtt_message(
|
||||
hass,
|
||||
"fully/event/onScreensaverStop/abcdef-123456",
|
||||
'{"deviceId": "abcdef-123456","event": "onScreensaverStop"}',
|
||||
)
|
||||
entity = hass.states.get("switch.amazon_fire_screensaver")
|
||||
assert entity.state == "off"
|
||||
|
||||
async_fire_mqtt_message(hass, "fully/event/screenOff/abcdef-123456", "{}")
|
||||
async_fire_mqtt_message(
|
||||
hass,
|
||||
"fully/event/screenOff/abcdef-123456",
|
||||
'{"deviceId": "abcdef-123456","event": "screenOff"}',
|
||||
)
|
||||
entity = hass.states.get("switch.amazon_fire_screen")
|
||||
assert entity.state == "off"
|
||||
|
||||
async_fire_mqtt_message(hass, "fully/event/screenOn/abcdef-123456", "{}")
|
||||
async_fire_mqtt_message(
|
||||
hass,
|
||||
"fully/event/screenOn/abcdef-123456",
|
||||
'{"deviceId": "abcdef-123456","event": "screenOn"}',
|
||||
)
|
||||
entity = hass.states.get("switch.amazon_fire_screen")
|
||||
assert entity.state == "on"
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue