parent
e55ce61100
commit
ed2b9e5483
26 changed files with 70 additions and 58 deletions
|
@ -10,7 +10,7 @@ import requests
|
|||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||
from homeassistant.const import CONF_CURRENCY
|
||||
from homeassistant.const import CONF_CURRENCY, POWER_WATT
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
||||
|
@ -34,11 +34,11 @@ DEFAULT_PERIOD = 'year'
|
|||
DEFAULT_UTC_OFFSET = '0'
|
||||
|
||||
SENSOR_TYPES = {
|
||||
CONF_INSTANT: ['Energy Usage', 'W'],
|
||||
CONF_INSTANT: ['Energy Usage', POWER_WATT],
|
||||
CONF_AMOUNT: ['Energy Consumed', 'kWh'],
|
||||
CONF_BUDGET: ['Energy Budget', None],
|
||||
CONF_COST: ['Energy Cost', None],
|
||||
CONF_CURRENT_VALUES: ['Per-Device Usage', 'W']
|
||||
CONF_CURRENT_VALUES: ['Per-Device Usage', POWER_WATT]
|
||||
}
|
||||
|
||||
TYPES_SCHEMA = vol.In(SENSOR_TYPES)
|
||||
|
|
|
@ -10,7 +10,7 @@ import logging
|
|||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||
from homeassistant.const import (CONF_ACCESS_TOKEN, CONF_NAME)
|
||||
from homeassistant.const import (CONF_ACCESS_TOKEN, CONF_NAME, POWER_WATT)
|
||||
from homeassistant.helpers.entity import Entity
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
|
@ -27,7 +27,7 @@ ICON = 'mdi:gauge'
|
|||
|
||||
SCAN_INTERVAL = timedelta(seconds=60)
|
||||
|
||||
UNIT_OF_MEASUREMENT = 'W'
|
||||
UNIT_OF_MEASUREMENT = POWER_WATT
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
vol.Required(CONF_ACCESS_TOKEN): cv.string,
|
||||
|
|
|
@ -14,7 +14,7 @@ import homeassistant.helpers.config_validation as cv
|
|||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||
from homeassistant.const import (
|
||||
CONF_API_KEY, CONF_URL, CONF_VALUE_TEMPLATE, CONF_UNIT_OF_MEASUREMENT,
|
||||
CONF_ID, CONF_SCAN_INTERVAL, STATE_UNKNOWN)
|
||||
CONF_ID, CONF_SCAN_INTERVAL, STATE_UNKNOWN, POWER_WATT)
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.helpers import template
|
||||
from homeassistant.util import Throttle
|
||||
|
@ -34,7 +34,7 @@ CONF_ONLY_INCLUDE_FEEDID = 'include_only_feed_id'
|
|||
CONF_SENSOR_NAMES = 'sensor_names'
|
||||
|
||||
DECIMALS = 2
|
||||
DEFAULT_UNIT = 'W'
|
||||
DEFAULT_UNIT = POWER_WATT
|
||||
|
||||
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=5)
|
||||
|
||||
|
|
|
@ -11,14 +11,15 @@ import voluptuous as vol
|
|||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.const import (CONF_IP_ADDRESS, CONF_MONITORED_CONDITIONS)
|
||||
from homeassistant.const import (
|
||||
CONF_IP_ADDRESS, CONF_MONITORED_CONDITIONS, POWER_WATT)
|
||||
|
||||
|
||||
REQUIREMENTS = ['envoy_reader==0.3']
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
SENSORS = {
|
||||
"production": ("Envoy Current Energy Production", 'W'),
|
||||
"production": ("Envoy Current Energy Production", POWER_WATT),
|
||||
"daily_production": ("Envoy Today's Energy Production", "Wh"),
|
||||
"seven_days_production": ("Envoy Last Seven Days Energy Production", "Wh"),
|
||||
"lifetime_production": ("Envoy Lifetime Energy Production", "Wh"),
|
||||
|
|
|
@ -6,7 +6,7 @@ https://home-assistant.io/components/sensors.greeneye_monitor_temperature/
|
|||
"""
|
||||
import logging
|
||||
|
||||
from homeassistant.const import CONF_NAME, CONF_TEMPERATURE_UNIT
|
||||
from homeassistant.const import CONF_NAME, CONF_TEMPERATURE_UNIT, POWER_WATT
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
||||
from ..greeneye_monitor import (
|
||||
|
@ -33,7 +33,7 @@ DEPENDENCIES = ['greeneye_monitor']
|
|||
DATA_PULSES = 'pulses'
|
||||
DATA_WATT_SECONDS = 'watt_seconds'
|
||||
|
||||
UNIT_WATTS = 'W'
|
||||
UNIT_WATTS = POWER_WATT
|
||||
|
||||
COUNTER_ICON = 'mdi:counter'
|
||||
CURRENT_SENSOR_ICON = 'mdi:flash'
|
||||
|
|
|
@ -11,7 +11,7 @@ import requests.exceptions
|
|||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||
from homeassistant.const import (CONF_API_KEY)
|
||||
from homeassistant.const import (CONF_API_KEY, POWER_WATT)
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.util import Throttle
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
@ -148,7 +148,7 @@ class NeurioEnergy(Entity):
|
|||
self._state = None
|
||||
|
||||
if sensor_type == ACTIVE_TYPE:
|
||||
self._unit_of_measurement = 'W'
|
||||
self._unit_of_measurement = POWER_WATT
|
||||
elif sensor_type == DAILY_TYPE:
|
||||
self._unit_of_measurement = 'kWh'
|
||||
|
||||
|
|
|
@ -13,7 +13,8 @@ from homeassistant.components.sensor import PLATFORM_SCHEMA
|
|||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.const import (
|
||||
CONF_HOST, CONF_PORT, CONF_NAME, CONF_USERNAME, CONF_PASSWORD,
|
||||
TEMP_CELSIUS, CONF_RESOURCES, CONF_ALIAS, ATTR_STATE, STATE_UNKNOWN)
|
||||
TEMP_CELSIUS, CONF_RESOURCES, CONF_ALIAS, ATTR_STATE, STATE_UNKNOWN,
|
||||
POWER_WATT)
|
||||
from homeassistant.exceptions import PlatformNotReady
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.util import Throttle
|
||||
|
@ -63,8 +64,8 @@ SENSOR_TYPES = {
|
|||
'ups.efficiency': ['Efficiency', '%', 'mdi:gauge'],
|
||||
'ups.power': ['Current Apparent Power', 'VA', 'mdi:flash'],
|
||||
'ups.power.nominal': ['Nominal Power', 'VA', 'mdi:flash'],
|
||||
'ups.realpower': ['Current Real Power', 'W', 'mdi:flash'],
|
||||
'ups.realpower.nominal': ['Nominal Real Power', 'W', 'mdi:flash'],
|
||||
'ups.realpower': ['Current Real Power', POWER_WATT, 'mdi:flash'],
|
||||
'ups.realpower.nominal': ['Nominal Real Power', POWER_WATT, 'mdi:flash'],
|
||||
'ups.beeper.status': ['Beeper Status', '', 'mdi:information-outline'],
|
||||
'ups.type': ['UPS Type', '', 'mdi:information-outline'],
|
||||
'ups.watchdog.status': ['Watchdog Status', '', 'mdi:information-outline'],
|
||||
|
|
|
@ -12,7 +12,7 @@ import voluptuous as vol
|
|||
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||
from homeassistant.const import (
|
||||
CONF_API_KEY, CONF_MONITORED_CONDITIONS, CONF_NAME)
|
||||
CONF_API_KEY, CONF_MONITORED_CONDITIONS, CONF_NAME, POWER_WATT)
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.util import Throttle
|
||||
|
@ -36,7 +36,7 @@ SENSOR_TYPES = {
|
|||
'mdi:solar-power'],
|
||||
'energy_today': ['lastDayData', "Energy today", 'Wh',
|
||||
'mdi:solar-power'],
|
||||
'current_power': ['currentPower', "Current Power", 'W',
|
||||
'current_power': ['currentPower', "Current Power", POWER_WATT,
|
||||
'mdi:solar-power']
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,8 @@ import requests
|
|||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||
from homeassistant.const import (CONF_HOST, CONF_NAME, CONF_PORT)
|
||||
from homeassistant.const import (
|
||||
CONF_HOST, CONF_NAME, CONF_PORT, POWER_WATT)
|
||||
from homeassistant.helpers import config_validation as cv
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.util import Throttle
|
||||
|
@ -46,7 +47,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
|||
|
||||
dev = []
|
||||
for mtu in gateway.data:
|
||||
dev.append(Ted5000Sensor(gateway, name, mtu, 'W'))
|
||||
dev.append(Ted5000Sensor(gateway, name, mtu, POWER_WATT))
|
||||
dev.append(Ted5000Sensor(gateway, name, mtu, 'V'))
|
||||
|
||||
add_entities(dev)
|
||||
|
@ -58,7 +59,7 @@ class Ted5000Sensor(Entity):
|
|||
|
||||
def __init__(self, gateway, name, mtu, unit):
|
||||
"""Initialize the sensor."""
|
||||
units = {'W': 'power', 'V': 'voltage'}
|
||||
units = {POWER_WATT: 'power', 'V': 'voltage'}
|
||||
self._gateway = gateway
|
||||
self._name = '{} mtu{} {}'.format(name, mtu, units[unit])
|
||||
self._mtu = mtu
|
||||
|
@ -114,4 +115,4 @@ class Ted5000Gateway:
|
|||
voltage = int(doc["LiveData"]["Voltage"]["MTU%d" % mtu]
|
||||
["VoltageNow"])
|
||||
|
||||
self.data[mtu] = {'W': power, 'V': voltage / 10}
|
||||
self.data[mtu] = {POWER_WATT: power, 'V': voltage / 10}
|
||||
|
|
|
@ -11,7 +11,7 @@ import voluptuous as vol
|
|||
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||
from homeassistant.const import (
|
||||
CONF_HOST, CONF_NAME, CONF_PORT, CONF_MONITORED_CONDITIONS)
|
||||
CONF_HOST, CONF_NAME, CONF_PORT, CONF_MONITORED_CONDITIONS, POWER_WATT)
|
||||
from homeassistant.exceptions import PlatformNotReady
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
@ -31,10 +31,10 @@ DEFAULT_PORT = 80
|
|||
MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=1)
|
||||
|
||||
SENSOR_TYPES = {
|
||||
'average': ['Average', 'W', 'mdi:power-off'],
|
||||
'average': ['Average', POWER_WATT, 'mdi:power-off'],
|
||||
'consumption': ['Consumption', 'Wh', 'mdi:power-plug'],
|
||||
'max': ['Max', 'W', 'mdi:arrow-up'],
|
||||
'min': ['Min', 'W', 'mdi:arrow-down'],
|
||||
'max': ['Max', POWER_WATT, 'mdi:arrow-up'],
|
||||
'min': ['Min', POWER_WATT, 'mdi:arrow-down'],
|
||||
}
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue