Migrate attribution attribute for Arlo (#57504)
This commit is contained in:
parent
1a68784852
commit
f561543e92
2 changed files with 9 additions and 5 deletions
|
@ -12,7 +12,6 @@ from homeassistant.components.sensor import (
|
|||
SensorEntityDescription,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
ATTR_ATTRIBUTION,
|
||||
CONCENTRATION_PARTS_PER_MILLION,
|
||||
CONF_MONITORED_CONDITIONS,
|
||||
DEVICE_CLASS_BATTERY,
|
||||
|
@ -123,6 +122,8 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
|||
class ArloSensor(SensorEntity):
|
||||
"""An implementation of a Netgear Arlo IP sensor."""
|
||||
|
||||
_attr_attribution = ATTRIBUTION
|
||||
|
||||
def __init__(self, device, sensor_entry):
|
||||
"""Initialize an Arlo sensor."""
|
||||
self.entity_description = sensor_entry
|
||||
|
@ -212,7 +213,6 @@ class ArloSensor(SensorEntity):
|
|||
"""Return the device state attributes."""
|
||||
attrs = {}
|
||||
|
||||
attrs[ATTR_ATTRIBUTION] = ATTRIBUTION
|
||||
attrs["brand"] = DEFAULT_BRAND
|
||||
|
||||
if self.entity_description.key != "total_cameras":
|
||||
|
|
|
@ -7,7 +7,6 @@ import pytest
|
|||
from homeassistant.components.arlo import DATA_ARLO, sensor as arlo
|
||||
from homeassistant.components.arlo.sensor import SENSOR_TYPES
|
||||
from homeassistant.const import (
|
||||
ATTR_ATTRIBUTION,
|
||||
DEVICE_CLASS_BATTERY,
|
||||
DEVICE_CLASS_HUMIDITY,
|
||||
DEVICE_CLASS_TEMPERATURE,
|
||||
|
@ -179,6 +178,13 @@ def test_device_class(default_sensor, temperature_sensor, humidity_sensor):
|
|||
assert humidity_sensor.device_class == DEVICE_CLASS_HUMIDITY
|
||||
|
||||
|
||||
def test_attribution(default_sensor, temperature_sensor, humidity_sensor):
|
||||
"""Test the device_class property."""
|
||||
assert default_sensor.attribution == "Data provided by arlo.netgear.com"
|
||||
assert temperature_sensor.attribution == "Data provided by arlo.netgear.com"
|
||||
assert humidity_sensor.attribution == "Data provided by arlo.netgear.com"
|
||||
|
||||
|
||||
def test_update_total_cameras(cameras_sensor):
|
||||
"""Test update method for total_cameras sensor type."""
|
||||
cameras_sensor.update()
|
||||
|
@ -195,7 +201,6 @@ def _test_attributes(hass, sensor_type):
|
|||
data = _get_named_tuple({"model_id": "TEST123"})
|
||||
sensor = _get_sensor(hass, "test", sensor_type, data)
|
||||
attrs = sensor.extra_state_attributes
|
||||
assert attrs.get(ATTR_ATTRIBUTION) == "Data provided by arlo.netgear.com"
|
||||
assert attrs.get("brand") == "Netgear Arlo"
|
||||
assert attrs.get("model") == "TEST123"
|
||||
|
||||
|
@ -212,7 +217,6 @@ def test_state_attributes(hass):
|
|||
def test_attributes_total_cameras(cameras_sensor):
|
||||
"""Test attributes for total cameras sensor type."""
|
||||
attrs = cameras_sensor.extra_state_attributes
|
||||
assert attrs.get(ATTR_ATTRIBUTION) == "Data provided by arlo.netgear.com"
|
||||
assert attrs.get("brand") == "Netgear Arlo"
|
||||
assert attrs.get("model") is None
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue