mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Move consts to 'const.py' (#7909)
This commit is contained in:
parent
f8cfa15152
commit
f303f6a191
@ -22,14 +22,13 @@ from homeassistant.components.media_player import (
|
|||||||
SUPPORT_PLAY)
|
SUPPORT_PLAY)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
STATE_IDLE, STATE_PAUSED, STATE_PLAYING, STATE_OFF, ATTR_ENTITY_ID,
|
STATE_IDLE, STATE_PAUSED, STATE_PLAYING, STATE_OFF, ATTR_ENTITY_ID,
|
||||||
CONF_HOSTS)
|
CONF_HOSTS, ATTR_TIME)
|
||||||
from homeassistant.config import load_yaml_config_file
|
from homeassistant.config import load_yaml_config_file
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.util.dt import utcnow
|
from homeassistant.util.dt import utcnow
|
||||||
|
|
||||||
REQUIREMENTS = ['SoCo==0.12']
|
REQUIREMENTS = ['SoCo==0.12']
|
||||||
|
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
# The soco library is excessively chatty when it comes to logging and
|
# The soco library is excessively chatty when it comes to logging and
|
||||||
@ -68,7 +67,6 @@ ATTR_ALARM_ID = 'alarm_id'
|
|||||||
ATTR_VOLUME = 'volume'
|
ATTR_VOLUME = 'volume'
|
||||||
ATTR_ENABLED = 'enabled'
|
ATTR_ENABLED = 'enabled'
|
||||||
ATTR_INCLUDE_LINKED_ZONES = 'include_linked_zones'
|
ATTR_INCLUDE_LINKED_ZONES = 'include_linked_zones'
|
||||||
ATTR_TIME = 'time'
|
|
||||||
ATTR_MASTER = 'master'
|
ATTR_MASTER = 'master'
|
||||||
ATTR_WITH_GROUP = 'with_group'
|
ATTR_WITH_GROUP = 'with_group'
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ from homeassistant.helpers.entity import Entity
|
|||||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_NAME, CONF_PORT, CONF_USERNAME, CONF_PASSWORD, CONF_VALUE_TEMPLATE,
|
CONF_NAME, CONF_PORT, CONF_USERNAME, CONF_PASSWORD, CONF_VALUE_TEMPLATE,
|
||||||
CONTENT_TYPE_TEXT_PLAIN)
|
CONTENT_TYPE_TEXT_PLAIN, ATTR_DATE)
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
@ -25,7 +25,6 @@ CONF_SENDERS = 'senders'
|
|||||||
|
|
||||||
ATTR_FROM = 'from'
|
ATTR_FROM = 'from'
|
||||||
ATTR_BODY = 'body'
|
ATTR_BODY = 'body'
|
||||||
ATTR_DATE = 'date'
|
|
||||||
ATTR_SUBJECT = 'subject'
|
ATTR_SUBJECT = 'subject'
|
||||||
|
|
||||||
DEFAULT_PORT = 993
|
DEFAULT_PORT = 993
|
||||||
@ -59,7 +58,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
class EmailReader:
|
class EmailReader(object):
|
||||||
"""A class to read emails from an IMAP server."""
|
"""A class to read emails from an IMAP server."""
|
||||||
|
|
||||||
def __init__(self, user, password, server, port):
|
def __init__(self, user, password, server, port):
|
||||||
|
@ -6,6 +6,7 @@ https://home-assistant.io/components/sensor.pvoutput/
|
|||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
from datetime import timedelta
|
||||||
|
|
||||||
import voluptuous as vol
|
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 import PLATFORM_SCHEMA
|
||||||
from homeassistant.components.sensor.rest import RestData
|
from homeassistant.components.sensor.rest import RestData
|
||||||
from homeassistant.const import (
|
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__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
_ENDPOINT = 'http://pvoutput.org/service/r2/getstatus.jsp'
|
_ENDPOINT = 'http://pvoutput.org/service/r2/getstatus.jsp'
|
||||||
|
|
||||||
ATTR_DATE = 'date'
|
|
||||||
ATTR_TIME = 'time'
|
|
||||||
ATTR_ENERGY_GENERATION = 'energy_generation'
|
ATTR_ENERGY_GENERATION = 'energy_generation'
|
||||||
ATTR_POWER_GENERATION = 'power_generation'
|
ATTR_POWER_GENERATION = 'power_generation'
|
||||||
ATTR_ENERGY_CONSUMPTION = 'energy_consumption'
|
ATTR_ENERGY_CONSUMPTION = 'energy_consumption'
|
||||||
@ -33,6 +33,8 @@ CONF_SYSTEM_ID = 'system_id'
|
|||||||
DEFAULT_NAME = 'PVOutput'
|
DEFAULT_NAME = 'PVOutput'
|
||||||
DEFAULT_VERIFY_SSL = True
|
DEFAULT_VERIFY_SSL = True
|
||||||
|
|
||||||
|
SCAN_INTERVAL = timedelta(minutes=2)
|
||||||
|
|
||||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||||
vol.Required(CONF_API_KEY): cv.string,
|
vol.Required(CONF_API_KEY): cv.string,
|
||||||
vol.Required(CONF_SYSTEM_ID): 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")
|
_LOGGER.error("Unable to fetch data from PVOutput")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
add_devices([PvoutputSensor(rest, name)])
|
add_devices([PvoutputSensor(rest, name)], True)
|
||||||
|
|
||||||
|
|
||||||
# pylint: disable=no-member
|
# pylint: disable=no-member
|
||||||
@ -71,15 +73,13 @@ class PvoutputSensor(Entity):
|
|||||||
"""Initialize a PVOutput sensor."""
|
"""Initialize a PVOutput sensor."""
|
||||||
self.rest = rest
|
self.rest = rest
|
||||||
self._name = name
|
self._name = name
|
||||||
self.pvcoutput = False
|
self.pvcoutput = None
|
||||||
self.status = namedtuple(
|
self.status = namedtuple(
|
||||||
'status', [ATTR_DATE, ATTR_TIME, ATTR_ENERGY_GENERATION,
|
'status', [ATTR_DATE, ATTR_TIME, ATTR_ENERGY_GENERATION,
|
||||||
ATTR_POWER_GENERATION, ATTR_ENERGY_CONSUMPTION,
|
ATTR_POWER_GENERATION, ATTR_ENERGY_CONSUMPTION,
|
||||||
ATTR_POWER_CONSUMPTION, ATTR_EFFICIENCY,
|
ATTR_POWER_CONSUMPTION, ATTR_EFFICIENCY,
|
||||||
ATTR_TEMPERATURE, ATTR_VOLTAGE])
|
ATTR_TEMPERATURE, ATTR_VOLTAGE])
|
||||||
|
|
||||||
self.update()
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
"""Return the name of the sensor."""
|
"""Return the name of the sensor."""
|
||||||
|
@ -10,7 +10,7 @@ from datetime import timedelta
|
|||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_ATTRIBUTION, ATTR_TEMPERATURE, STATE_UNKNOWN)
|
ATTR_ATTRIBUTION, ATTR_TIME, ATTR_TEMPERATURE, STATE_UNKNOWN)
|
||||||
from homeassistant.helpers import config_validation as cv
|
from homeassistant.helpers import config_validation as cv
|
||||||
from homeassistant.helpers.config_validation import PLATFORM_SCHEMA
|
from homeassistant.helpers.config_validation import PLATFORM_SCHEMA
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
@ -28,7 +28,6 @@ ATTR_PM10 = 'pm_10'
|
|||||||
ATTR_PM2_5 = 'pm_2_5'
|
ATTR_PM2_5 = 'pm_2_5'
|
||||||
ATTR_PRESSURE = 'pressure'
|
ATTR_PRESSURE = 'pressure'
|
||||||
ATTR_SULFUR_DIOXIDE = 'sulfur_dioxide'
|
ATTR_SULFUR_DIOXIDE = 'sulfur_dioxide'
|
||||||
ATTR_TIME = 'time'
|
|
||||||
ATTRIBUTION = 'Data provided by the World Air Quality Index project'
|
ATTRIBUTION = 'Data provided by the World Air Quality Index project'
|
||||||
|
|
||||||
CONF_LOCATIONS = 'locations'
|
CONF_LOCATIONS = 'locations'
|
||||||
|
@ -202,8 +202,10 @@ STATE_UNAVAILABLE = 'unavailable'
|
|||||||
# Attribution
|
# Attribution
|
||||||
ATTR_ATTRIBUTION = 'attribution'
|
ATTR_ATTRIBUTION = 'attribution'
|
||||||
|
|
||||||
# Contains current time for a TIME_CHANGED event
|
# Contains time-related attributes
|
||||||
ATTR_NOW = 'now'
|
ATTR_NOW = 'now'
|
||||||
|
ATTR_DATE = 'date'
|
||||||
|
ATTR_TIME = 'time'
|
||||||
|
|
||||||
# Contains domain, service for a SERVICE_CALL event
|
# Contains domain, service for a SERVICE_CALL event
|
||||||
ATTR_DOMAIN = 'domain'
|
ATTR_DOMAIN = 'domain'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user