mirror of
https://github.com/home-assistant/core.git
synced 2025-07-10 14:57:09 +00:00
Migrate attribution attribute for Arlo (#57504)
This commit is contained in:
parent
1a68784852
commit
f561543e92
@ -12,7 +12,6 @@ from homeassistant.components.sensor import (
|
|||||||
SensorEntityDescription,
|
SensorEntityDescription,
|
||||||
)
|
)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_ATTRIBUTION,
|
|
||||||
CONCENTRATION_PARTS_PER_MILLION,
|
CONCENTRATION_PARTS_PER_MILLION,
|
||||||
CONF_MONITORED_CONDITIONS,
|
CONF_MONITORED_CONDITIONS,
|
||||||
DEVICE_CLASS_BATTERY,
|
DEVICE_CLASS_BATTERY,
|
||||||
@ -123,6 +122,8 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
|||||||
class ArloSensor(SensorEntity):
|
class ArloSensor(SensorEntity):
|
||||||
"""An implementation of a Netgear Arlo IP sensor."""
|
"""An implementation of a Netgear Arlo IP sensor."""
|
||||||
|
|
||||||
|
_attr_attribution = ATTRIBUTION
|
||||||
|
|
||||||
def __init__(self, device, sensor_entry):
|
def __init__(self, device, sensor_entry):
|
||||||
"""Initialize an Arlo sensor."""
|
"""Initialize an Arlo sensor."""
|
||||||
self.entity_description = sensor_entry
|
self.entity_description = sensor_entry
|
||||||
@ -212,7 +213,6 @@ class ArloSensor(SensorEntity):
|
|||||||
"""Return the device state attributes."""
|
"""Return the device state attributes."""
|
||||||
attrs = {}
|
attrs = {}
|
||||||
|
|
||||||
attrs[ATTR_ATTRIBUTION] = ATTRIBUTION
|
|
||||||
attrs["brand"] = DEFAULT_BRAND
|
attrs["brand"] = DEFAULT_BRAND
|
||||||
|
|
||||||
if self.entity_description.key != "total_cameras":
|
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 import DATA_ARLO, sensor as arlo
|
||||||
from homeassistant.components.arlo.sensor import SENSOR_TYPES
|
from homeassistant.components.arlo.sensor import SENSOR_TYPES
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_ATTRIBUTION,
|
|
||||||
DEVICE_CLASS_BATTERY,
|
DEVICE_CLASS_BATTERY,
|
||||||
DEVICE_CLASS_HUMIDITY,
|
DEVICE_CLASS_HUMIDITY,
|
||||||
DEVICE_CLASS_TEMPERATURE,
|
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
|
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):
|
def test_update_total_cameras(cameras_sensor):
|
||||||
"""Test update method for total_cameras sensor type."""
|
"""Test update method for total_cameras sensor type."""
|
||||||
cameras_sensor.update()
|
cameras_sensor.update()
|
||||||
@ -195,7 +201,6 @@ def _test_attributes(hass, sensor_type):
|
|||||||
data = _get_named_tuple({"model_id": "TEST123"})
|
data = _get_named_tuple({"model_id": "TEST123"})
|
||||||
sensor = _get_sensor(hass, "test", sensor_type, data)
|
sensor = _get_sensor(hass, "test", sensor_type, data)
|
||||||
attrs = sensor.extra_state_attributes
|
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("brand") == "Netgear Arlo"
|
||||||
assert attrs.get("model") == "TEST123"
|
assert attrs.get("model") == "TEST123"
|
||||||
|
|
||||||
@ -212,7 +217,6 @@ def test_state_attributes(hass):
|
|||||||
def test_attributes_total_cameras(cameras_sensor):
|
def test_attributes_total_cameras(cameras_sensor):
|
||||||
"""Test attributes for total cameras sensor type."""
|
"""Test attributes for total cameras sensor type."""
|
||||||
attrs = cameras_sensor.extra_state_attributes
|
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("brand") == "Netgear Arlo"
|
||||||
assert attrs.get("model") is None
|
assert attrs.get("model") is None
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user