Skip to content

Commit

Permalink
Bump axis to v60 (home-assistant#114544)
Browse files Browse the repository at this point in the history
* Improve Axis MQTT support

* Bump axis to v60
  • Loading branch information
Kane610 authored and balloob committed Apr 2, 2024
1 parent ef97255 commit 14dfb6a
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 7 deletions.
5 changes: 3 additions & 2 deletions homeassistant/components/axis/hub/hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,16 @@ async def async_use_mqtt(self, hass: HomeAssistant, component: str) -> None:
if status.status.state == ClientState.ACTIVE:
self.config.entry.async_on_unload(
await mqtt.async_subscribe(
hass, f"{self.api.vapix.serial_number}/#", self.mqtt_message
hass, f"{status.config.device_topic_prefix}/#", self.mqtt_message
)
)

@callback
def mqtt_message(self, message: ReceiveMessage) -> None:
"""Receive Axis MQTT message."""
self.disconnect_from_stream()

if message.topic.endswith("event/connection"):
return
event = mqtt_json_to_event(message.payload)
self.api.event.handler(event)

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/axis/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"iot_class": "local_push",
"loggers": ["axis"],
"quality_scale": "platinum",
"requirements": ["axis==59"],
"requirements": ["axis==60"],
"ssdp": [
{
"manufacturer": "AXIS"
Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ aurorapy==0.2.7
# avion==0.10

# homeassistant.components.axis
axis==59
axis==60

# homeassistant.components.azure_event_hub
azure-eventhub==5.11.1
Expand Down
2 changes: 1 addition & 1 deletion requirements_test_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ auroranoaa==0.0.3
aurorapy==0.2.7

# homeassistant.components.axis
axis==59
axis==60

# homeassistant.components.azure_event_hub
azure-eventhub==5.11.1
Expand Down
1 change: 1 addition & 0 deletions tests/components/axis/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"status": {"state": "active", "connectionStatus": "Connected"},
"config": {
"server": {"protocol": "tcp", "host": "192.168.0.90", "port": 1883},
"deviceTopicPrefix": f"axis/{MAC}",
},
},
}
Expand Down
4 changes: 2 additions & 2 deletions tests/components/axis/test_hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ async def test_device_support_mqtt(
hass: HomeAssistant, mqtt_mock: MqttMockHAClient, setup_config_entry
) -> None:
"""Successful setup."""
mqtt_mock.async_subscribe.assert_called_with(f"{MAC}/#", mock.ANY, 0, "utf-8")
mqtt_mock.async_subscribe.assert_called_with(f"axis/{MAC}/#", mock.ANY, 0, "utf-8")

topic = f"{MAC}/event/tns:onvif/Device/tns:axis/Sensor/PIR/$source/sensor/0"
topic = f"axis/{MAC}/event/tns:onvif/Device/tns:axis/Sensor/PIR/$source/sensor/0"
message = (
b'{"timestamp": 1590258472044, "topic": "onvif:Device/axis:Sensor/PIR",'
b' "message": {"source": {"sensor": "0"}, "key": {}, "data": {"state": "1"}}}'
Expand Down

0 comments on commit 14dfb6a

Please sign in to comment.