Move consts to 'const.py' (#7909)

This commit is contained in:
Fabian Affolter authored and GitHub committed 2017-06-05 16:59:59 +02:00
1 parent f8cfa15152
commit f303f6a191
5 files changed
+14 -16

No files matched your search

+7 -7
View File
@@ -6,6 +6,7 @@ https://home-assistant.io/components/sensor.pvoutput/
"""
import logging
from collections import namedtuple
from datetime import timedelta
import voluptuous as vol
@@ -14,13 +15,12 @@ from homeassistant.helpers.entity import Entity
from homeassistant.components.sensor import PLATFORM_SCHEMA
from homeassistant.components.sensor.rest import RestData
from homeassistant.const import (
ATTR_TEMPERATURE, CONF_API_KEY, CONF_NAME, STATE_UNKNOWN)
ATTR_TEMPERATURE, CONF_API_KEY, CONF_NAME, STATE_UNKNOWN, ATTR_DATE,
ATTR_TIME)
_LOGGER = logging.getLogger(__name__)
_ENDPOINT = 'http://pvoutput.org/service/r2/getstatus.jsp'
ATTR_DATE = 'date'
ATTR_TIME = 'time'
ATTR_ENERGY_GENERATION = 'energy_generation'
ATTR_POWER_GENERATION = 'power_generation'
ATTR_ENERGY_CONSUMPTION = 'energy_consumption'
@@ -33,6 +33,8 @@ CONF_SYSTEM_ID = 'system_id'
DEFAULT_NAME = 'PVOutput'
DEFAULT_VERIFY_SSL = True
SCAN_INTERVAL = timedelta(minutes=2)
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_API_KEY): cv.string,
vol.Required(CONF_SYSTEM_ID): cv.string,
@@ -60,7 +62,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
_LOGGER.error("Unable to fetch data from PVOutput")
return False
add_devices([PvoutputSensor(rest, name)])
add_devices([PvoutputSensor(rest, name)], True)
# pylint: disable=no-member
@@ -71,15 +73,13 @@ class PvoutputSensor(Entity):
"""Initialize a PVOutput sensor."""
self.rest = rest
self._name = name
self.pvcoutput = False
self.pvcoutput = None
self.status = namedtuple(
'status', [ATTR_DATE, ATTR_TIME, ATTR_ENERGY_GENERATION,
ATTR_POWER_GENERATION, ATTR_ENERGY_CONSUMPTION,
ATTR_POWER_CONSUMPTION, ATTR_EFFICIENCY,
ATTR_TEMPERATURE, ATTR_VOLTAGE])
self.update()
@property
def name(self):
"""Return the name of the sensor."""