Remove Axis option to enable/disable camera (#36420)
parent
a6107198b9
commit
99318b7b11
|
@ -27,7 +27,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||||
|
|
||||||
device = hass.data[AXIS_DOMAIN][config_entry.unique_id]
|
device = hass.data[AXIS_DOMAIN][config_entry.unique_id]
|
||||||
|
|
||||||
if not device.option_camera:
|
if not device.api.vapix.params.image_format:
|
||||||
return
|
return
|
||||||
|
|
||||||
async_add_entities([AxisCamera(device)])
|
async_add_entities([AxisCamera(device)])
|
||||||
|
|
|
@ -11,7 +11,6 @@ DOMAIN = "axis"
|
||||||
|
|
||||||
ATTR_MANUFACTURER = "Axis Communications AB"
|
ATTR_MANUFACTURER = "Axis Communications AB"
|
||||||
|
|
||||||
CONF_CAMERA = "camera"
|
|
||||||
CONF_EVENTS = "events"
|
CONF_EVENTS = "events"
|
||||||
CONF_MODEL = "model"
|
CONF_MODEL = "model"
|
||||||
CONF_STREAM_PROFILE = "stream_profile"
|
CONF_STREAM_PROFILE = "stream_profile"
|
||||||
|
|
|
@ -28,7 +28,6 @@ from homeassistant.setup import async_when_setup
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
ATTR_MANUFACTURER,
|
ATTR_MANUFACTURER,
|
||||||
CONF_CAMERA,
|
|
||||||
CONF_EVENTS,
|
CONF_EVENTS,
|
||||||
CONF_MODEL,
|
CONF_MODEL,
|
||||||
CONF_STREAM_PROFILE,
|
CONF_STREAM_PROFILE,
|
||||||
|
@ -77,12 +76,6 @@ class AxisNetworkDevice:
|
||||||
"""Return the serial number of this device."""
|
"""Return the serial number of this device."""
|
||||||
return self.config_entry.unique_id
|
return self.config_entry.unique_id
|
||||||
|
|
||||||
@property
|
|
||||||
def option_camera(self):
|
|
||||||
"""Config entry option defining if camera should be used."""
|
|
||||||
supported_formats = self.api.vapix.params.image_format
|
|
||||||
return self.config_entry.options.get(CONF_CAMERA, bool(supported_formats))
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def option_events(self):
|
def option_events(self):
|
||||||
"""Config entry option defining if platforms based on events should be created."""
|
"""Config entry option defining if platforms based on events should be created."""
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
from homeassistant.components import camera
|
from homeassistant.components import camera
|
||||||
from homeassistant.components.axis.const import (
|
from homeassistant.components.axis.const import (
|
||||||
CONF_CAMERA,
|
|
||||||
CONF_STREAM_PROFILE,
|
CONF_STREAM_PROFILE,
|
||||||
DOMAIN as AXIS_DOMAIN,
|
DOMAIN as AXIS_DOMAIN,
|
||||||
)
|
)
|
||||||
|
@ -70,7 +69,7 @@ async def test_camera_with_stream_profile(hass):
|
||||||
|
|
||||||
async def test_camera_disabled(hass):
|
async def test_camera_disabled(hass):
|
||||||
"""Test that Axis camera platform is loaded properly but does not create camera entity."""
|
"""Test that Axis camera platform is loaded properly but does not create camera entity."""
|
||||||
with patch.dict(ENTRY_OPTIONS, {CONF_CAMERA: False}):
|
with patch("axis.vapix.Params.image_format", new=None):
|
||||||
await setup_axis_integration(hass)
|
await setup_axis_integration(hass)
|
||||||
|
|
||||||
assert len(hass.states.async_entity_ids(CAMERA_DOMAIN)) == 0
|
assert len(hass.states.async_entity_ids(CAMERA_DOMAIN)) == 0
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
from homeassistant import data_entry_flow
|
from homeassistant import data_entry_flow
|
||||||
from homeassistant.components.axis import config_flow
|
from homeassistant.components.axis import config_flow
|
||||||
from homeassistant.components.axis.const import (
|
from homeassistant.components.axis.const import (
|
||||||
CONF_CAMERA,
|
|
||||||
CONF_EVENTS,
|
CONF_EVENTS,
|
||||||
CONF_MODEL,
|
CONF_MODEL,
|
||||||
CONF_STREAM_PROFILE,
|
CONF_STREAM_PROFILE,
|
||||||
|
@ -352,7 +351,6 @@ async def test_option_flow(hass):
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||||
assert result["data"] == {
|
assert result["data"] == {
|
||||||
CONF_CAMERA: True,
|
|
||||||
CONF_EVENTS: True,
|
CONF_EVENTS: True,
|
||||||
CONF_STREAM_PROFILE: "profile_1",
|
CONF_STREAM_PROFILE: "profile_1",
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,6 @@ import pytest
|
||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
from homeassistant.components import axis
|
from homeassistant.components import axis
|
||||||
from homeassistant.components.axis.const import (
|
from homeassistant.components.axis.const import (
|
||||||
CONF_CAMERA,
|
|
||||||
CONF_EVENTS,
|
CONF_EVENTS,
|
||||||
CONF_MODEL,
|
CONF_MODEL,
|
||||||
DOMAIN as AXIS_DOMAIN,
|
DOMAIN as AXIS_DOMAIN,
|
||||||
|
@ -48,7 +47,7 @@ MAC = "00408C12345"
|
||||||
MODEL = "model"
|
MODEL = "model"
|
||||||
NAME = "name"
|
NAME = "name"
|
||||||
|
|
||||||
ENTRY_OPTIONS = {CONF_CAMERA: True, CONF_EVENTS: True}
|
ENTRY_OPTIONS = {CONF_EVENTS: True}
|
||||||
|
|
||||||
ENTRY_CONFIG = {
|
ENTRY_CONFIG = {
|
||||||
CONF_HOST: "1.2.3.4",
|
CONF_HOST: "1.2.3.4",
|
||||||
|
|
Loading…
Reference in New Issue