Add attribution to Sense component (#33657)
This commit is contained in:
parent
22ae498f3a
commit
d2e70eb967
3 changed files with 21 additions and 2 deletions
|
@ -2,12 +2,13 @@
|
|||
import logging
|
||||
|
||||
from homeassistant.components.binary_sensor import BinarySensorDevice
|
||||
from homeassistant.const import DEVICE_CLASS_POWER
|
||||
from homeassistant.const import ATTR_ATTRIBUTION, DEVICE_CLASS_POWER
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.entity_registry import async_get_registry
|
||||
|
||||
from .const import (
|
||||
ATTRIBUTION,
|
||||
DOMAIN,
|
||||
MDI_ICONS,
|
||||
SENSE_DATA,
|
||||
|
@ -100,6 +101,11 @@ class SenseDevice(BinarySensorDevice):
|
|||
"""Return the old not so unique id of the binary sensor."""
|
||||
return self._id
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
"""Return the state attributes."""
|
||||
return {ATTR_ATTRIBUTION: ATTRIBUTION}
|
||||
|
||||
@property
|
||||
def icon(self):
|
||||
"""Return the icon of the binary sensor."""
|
||||
|
|
|
@ -16,6 +16,8 @@ SENSE_DISCOVERED_DEVICES_DATA = "sense_discovered_devices"
|
|||
ACTIVE_NAME = "Energy"
|
||||
ACTIVE_TYPE = "active"
|
||||
|
||||
ATTRIBUTION = "Data provided by Sense.com"
|
||||
|
||||
CONSUMPTION_NAME = "Usage"
|
||||
CONSUMPTION_ID = "usage"
|
||||
PRODUCTION_NAME = "Production"
|
||||
|
|
|
@ -2,7 +2,12 @@
|
|||
from datetime import timedelta
|
||||
import logging
|
||||
|
||||
from homeassistant.const import DEVICE_CLASS_POWER, ENERGY_KILO_WATT_HOUR, POWER_WATT
|
||||
from homeassistant.const import (
|
||||
ATTR_ATTRIBUTION,
|
||||
DEVICE_CLASS_POWER,
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
POWER_WATT,
|
||||
)
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
@ -11,6 +16,7 @@ from homeassistant.util import Throttle
|
|||
from .const import (
|
||||
ACTIVE_NAME,
|
||||
ACTIVE_TYPE,
|
||||
ATTRIBUTION,
|
||||
CONSUMPTION_ID,
|
||||
CONSUMPTION_NAME,
|
||||
DOMAIN,
|
||||
|
@ -162,6 +168,11 @@ class SenseActiveSensor(Entity):
|
|||
"""Return the unit of measurement of this entity, if any."""
|
||||
return POWER_WATT
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
"""Return the state attributes."""
|
||||
return {ATTR_ATTRIBUTION: ATTRIBUTION}
|
||||
|
||||
@property
|
||||
def icon(self):
|
||||
"""Icon to use in the frontend, if any."""
|
||||
|
|
Loading…
Add table
Reference in a new issue