Bump axis to v46 (#85431)
This commit is contained in:
parent
54168c9bdb
commit
1cdd535f21
10 changed files with 111 additions and 127 deletions
|
@ -8,8 +8,7 @@ import async_timeout
|
|||
import axis
|
||||
from axis.configuration import Configuration
|
||||
from axis.errors import Unauthorized
|
||||
from axis.event_stream import OPERATION_INITIALIZED
|
||||
from axis.streammanager import SIGNAL_PLAYING, STATE_STOPPED
|
||||
from axis.stream_manager import Signal, State
|
||||
from axis.vapix.interfaces.mqtt import mqtt_json_to_event
|
||||
|
||||
from homeassistant.components import mqtt
|
||||
|
@ -129,11 +128,6 @@ class AxisNetworkDevice:
|
|||
"""Device specific event to signal a change in connection status."""
|
||||
return f"axis_reachable_{self.unique_id}"
|
||||
|
||||
@property
|
||||
def signal_new_event(self):
|
||||
"""Device specific event to signal new device event available."""
|
||||
return f"axis_new_event_{self.unique_id}"
|
||||
|
||||
@property
|
||||
def signal_new_address(self):
|
||||
"""Device specific event to signal a change in device address."""
|
||||
|
@ -149,16 +143,10 @@ class AxisNetworkDevice:
|
|||
Only signal state change if state change is true.
|
||||
"""
|
||||
|
||||
if self.available != (status == SIGNAL_PLAYING):
|
||||
if self.available != (status == Signal.PLAYING):
|
||||
self.available = not self.available
|
||||
async_dispatcher_send(self.hass, self.signal_reachable, True)
|
||||
|
||||
@callback
|
||||
def async_event_callback(self, action, event_id):
|
||||
"""Call to configure events when initialized on event stream."""
|
||||
if action == OPERATION_INITIALIZED:
|
||||
async_dispatcher_send(self.hass, self.signal_new_event, event_id)
|
||||
|
||||
@staticmethod
|
||||
async def async_new_address_callback(
|
||||
hass: HomeAssistant, entry: ConfigEntry
|
||||
|
@ -208,7 +196,7 @@ class AxisNetworkDevice:
|
|||
self.disconnect_from_stream()
|
||||
|
||||
event = mqtt_json_to_event(message.payload)
|
||||
self.api.event.update([event])
|
||||
self.api.event.handler(event)
|
||||
|
||||
# Setup and teardown methods
|
||||
|
||||
|
@ -219,7 +207,7 @@ class AxisNetworkDevice:
|
|||
self.api.stream.connection_status_callback.append(
|
||||
self.async_connection_status_callback
|
||||
)
|
||||
self.api.enable_events(event_callback=self.async_event_callback)
|
||||
self.api.enable_events()
|
||||
self.api.stream.start()
|
||||
|
||||
if self.api.vapix.mqtt:
|
||||
|
@ -228,7 +216,7 @@ class AxisNetworkDevice:
|
|||
@callback
|
||||
def disconnect_from_stream(self) -> None:
|
||||
"""Stop stream."""
|
||||
if self.api.stream.state != STATE_STOPPED:
|
||||
if self.api.stream.state != State.STOPPED:
|
||||
self.api.stream.connection_status_callback.clear()
|
||||
self.api.stream.stop()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue