Add device info to canary camera and sensors (#40053)

* add device info to canary sensors

* Update test_sensor.py

* Update sensor.py

* Update sensor.py

* Update test_sensor.py

* Create const.py

* Update sensor.py

* Update test_sensor.py

* Update sensor.py

* Update test_sensor.py

* Update camera.py

* Update camera.py

* Update sensor.py

* Update camera.py

* Update camera.py
This commit is contained in:
Chris Talkington authored and GitHub committed 2020-09-19 10:09:40 -05:00
1 parent 467a001e1f
commit 0c8b530aa2
4 files changed
+49 -5

No files matched your search

+16 -2
View File
@@ -24,6 +24,7 @@ from .const import (
DEFAULT_FFMPEG_ARGUMENTS,
DEFAULT_TIMEOUT,
DOMAIN,
MANUFACTURER,
)
_LOGGER = logging.getLogger(__name__)
@@ -77,18 +78,31 @@ class CanaryCamera(Camera):
self._data = data
self._location = location
self._device = device
self._device_id = device.device_id
self._device_name = device.name
self._device_type_name = device.device_type["name"]
self._timeout = timeout
self._live_stream_session = None
@property
def name(self):
"""Return the name of this device."""
return self._device.name
return self._device_name
@property
def unique_id(self):
"""Return the unique ID of this camera."""
return str(self._device.device_id)
return str(self._device_id)
@property
def device_info(self):
"""Return the device_info of the device."""
return {
"identifiers": {(DOMAIN, str(self._device_id))},
"name": self._device_name,
"model": self._device_type_name,
"manufacturer": MANUFACTURER,
}
@property
def is_recording(self):
+2
View File
@@ -2,6 +2,8 @@
DOMAIN = "canary"
MANUFACTURER = "Canary Connect, Inc"
# Configuration
CONF_FFMPEG_ARGUMENTS = "ffmpeg_arguments"
+13 -1
View File
@@ -16,7 +16,7 @@ from homeassistant.helpers.entity import Entity
from homeassistant.helpers.typing import HomeAssistantType
from . import CanaryData
from .const import DATA_CANARY, DOMAIN
from .const import DATA_CANARY, DOMAIN, MANUFACTURER
SENSOR_VALUE_PRECISION = 2
ATTR_AIR_QUALITY = "air_quality"
@@ -73,6 +73,8 @@ class CanarySensor(Entity):
self._data = data
self._sensor_type = sensor_type
self._device_id = device.device_id
self._device_name = device.name
self._device_type_name = device.device_type["name"]
self._sensor_value = None
sensor_type_name = sensor_type[0].replace("_", " ").title()
@@ -93,6 +95,16 @@ class CanarySensor(Entity):
"""Return the unique ID of this sensor."""
return f"{self._device_id}_{self._sensor_type[0]}"
@property
def device_info(self):
"""Return the device_info of the device."""
return {
"identifiers": {(DOMAIN, str(self._device_id))},
"name": self._device_name,
"model": self._device_type_name,
"manufacturer": MANUFACTURER,
}
@property
def unit_of_measurement(self):
"""Return the unit of measurement."""