From 99318b7b11080f3e4cc9644b660d935d52cec7c0 Mon Sep 17 00:00:00 2001 From: Robert Svensson Date: Thu, 4 Jun 2020 14:25:50 +0200 Subject: [PATCH] Remove Axis option to enable/disable camera (#36420) --- homeassistant/components/axis/camera.py | 2 +- homeassistant/components/axis/const.py | 1 - homeassistant/components/axis/device.py | 7 ------- tests/components/axis/test_camera.py | 3 +-- tests/components/axis/test_config_flow.py | 2 -- tests/components/axis/test_device.py | 3 +-- 6 files changed, 3 insertions(+), 15 deletions(-) diff --git a/homeassistant/components/axis/camera.py b/homeassistant/components/axis/camera.py index 8e7e4592cb6..69047268b07 100644 --- a/homeassistant/components/axis/camera.py +++ b/homeassistant/components/axis/camera.py @@ -27,7 +27,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): device = hass.data[AXIS_DOMAIN][config_entry.unique_id] - if not device.option_camera: + if not device.api.vapix.params.image_format: return async_add_entities([AxisCamera(device)]) diff --git a/homeassistant/components/axis/const.py b/homeassistant/components/axis/const.py index 203bbdf94c7..68c04ef0d72 100644 --- a/homeassistant/components/axis/const.py +++ b/homeassistant/components/axis/const.py @@ -11,7 +11,6 @@ DOMAIN = "axis" ATTR_MANUFACTURER = "Axis Communications AB" -CONF_CAMERA = "camera" CONF_EVENTS = "events" CONF_MODEL = "model" CONF_STREAM_PROFILE = "stream_profile" diff --git a/homeassistant/components/axis/device.py b/homeassistant/components/axis/device.py index 69cab856516..9d825fba0a5 100644 --- a/homeassistant/components/axis/device.py +++ b/homeassistant/components/axis/device.py @@ -28,7 +28,6 @@ from homeassistant.setup import async_when_setup from .const import ( ATTR_MANUFACTURER, - CONF_CAMERA, CONF_EVENTS, CONF_MODEL, CONF_STREAM_PROFILE, @@ -77,12 +76,6 @@ class AxisNetworkDevice: """Return the serial number of this device.""" 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 def option_events(self): """Config entry option defining if platforms based on events should be created.""" diff --git a/tests/components/axis/test_camera.py b/tests/components/axis/test_camera.py index 6db8de0a0a8..af276fe6fe5 100644 --- a/tests/components/axis/test_camera.py +++ b/tests/components/axis/test_camera.py @@ -2,7 +2,6 @@ from homeassistant.components import camera from homeassistant.components.axis.const import ( - CONF_CAMERA, CONF_STREAM_PROFILE, DOMAIN as AXIS_DOMAIN, ) @@ -70,7 +69,7 @@ async def test_camera_with_stream_profile(hass): async def test_camera_disabled(hass): """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) assert len(hass.states.async_entity_ids(CAMERA_DOMAIN)) == 0 diff --git a/tests/components/axis/test_config_flow.py b/tests/components/axis/test_config_flow.py index 941961f623a..aa7d9db9027 100644 --- a/tests/components/axis/test_config_flow.py +++ b/tests/components/axis/test_config_flow.py @@ -2,7 +2,6 @@ from homeassistant import data_entry_flow from homeassistant.components.axis import config_flow from homeassistant.components.axis.const import ( - CONF_CAMERA, CONF_EVENTS, CONF_MODEL, 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["data"] == { - CONF_CAMERA: True, CONF_EVENTS: True, CONF_STREAM_PROFILE: "profile_1", } diff --git a/tests/components/axis/test_device.py b/tests/components/axis/test_device.py index e4b0a960979..6fafdbae8cb 100644 --- a/tests/components/axis/test_device.py +++ b/tests/components/axis/test_device.py @@ -22,7 +22,6 @@ import pytest from homeassistant import config_entries from homeassistant.components import axis from homeassistant.components.axis.const import ( - CONF_CAMERA, CONF_EVENTS, CONF_MODEL, DOMAIN as AXIS_DOMAIN, @@ -48,7 +47,7 @@ MAC = "00408C12345" MODEL = "model" NAME = "name" -ENTRY_OPTIONS = {CONF_CAMERA: True, CONF_EVENTS: True} +ENTRY_OPTIONS = {CONF_EVENTS: True} ENTRY_CONFIG = { CONF_HOST: "1.2.3.4",