Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Axis - events now address devices individually #22477

Merged
merged 1 commit into from
Mar 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions homeassistant/components/axis/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ def async_add_sensor(event):
"""Add binary sensor from Axis device."""
async_add_entities([AxisBinarySensor(event, device)], True)

device.listeners.append(
async_dispatcher_connect(hass, 'axis_add_sensor', async_add_sensor))
device.listeners.append(async_dispatcher_connect(
hass, device.event_new_sensor, async_add_sensor))


class AxisBinarySensor(BinarySensorDevice):
Expand Down
7 changes: 6 additions & 1 deletion homeassistant/components/axis/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,16 @@ async def async_setup(self):

return True

@property
def event_new_sensor(self):
"""Device specific event to signal new sensor available."""
return 'axis_add_sensor_{}'.format(self.serial)

@callback
def async_signal_callback(self, action, event):
"""Call to configure events when initialized on event stream."""
if action == 'add':
async_dispatcher_send(self.hass, 'axis_add_sensor', event)
async_dispatcher_send(self.hass, self.event_new_sensor, event)

@callback
def shutdown(self, event):
Expand Down