Remove Axis option to enable/disable camera (#36420)

pull/36444/head
Robert Svensson 2020-06-04 14:25:50 +02:00 committed by GitHub
parent a6107198b9
commit 99318b7b11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 3 additions and 15 deletions

View File

@ -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)])

View File

@ -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"

View File

@ -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."""

View File

@ -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

View File

@ -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",
}

View File

@ -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",