Change STATE_UNKOWN to None (#20337)
* Change STATE_UNKOWN to None * Change STATE_UNKOWN to None * tests * tests * tests * tests * tests * style * fix comments * fix comments * update fan test
This commit is contained in:
parent
074fcd96ed
commit
1bd31e3459
64 changed files with 147 additions and 168 deletions
|
@ -13,7 +13,7 @@ import homeassistant.components.alarm_control_panel as alarm
|
||||||
from homeassistant.components.alarm_control_panel import PLATFORM_SCHEMA
|
from homeassistant.components.alarm_control_panel import PLATFORM_SCHEMA
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_CODE, CONF_NAME, CONF_PASSWORD, CONF_USERNAME, STATE_ALARM_ARMED_AWAY,
|
CONF_CODE, CONF_NAME, CONF_PASSWORD, CONF_USERNAME, STATE_ALARM_ARMED_AWAY,
|
||||||
STATE_ALARM_ARMED_HOME, STATE_ALARM_DISARMED, STATE_UNKNOWN)
|
STATE_ALARM_ARMED_HOME, STATE_ALARM_DISARMED)
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ class AlarmDotCom(alarm.AlarmControlPanel):
|
||||||
self._username = username
|
self._username = username
|
||||||
self._password = password
|
self._password = password
|
||||||
self._websession = async_get_clientsession(self._hass)
|
self._websession = async_get_clientsession(self._hass)
|
||||||
self._state = STATE_UNKNOWN
|
self._state = None
|
||||||
self._alarm = Alarmdotcom(
|
self._alarm = Alarmdotcom(
|
||||||
username, password, self._websession, hass.loop)
|
username, password, self._websession, hass.loop)
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ class AlarmDotCom(alarm.AlarmControlPanel):
|
||||||
return STATE_ALARM_ARMED_HOME
|
return STATE_ALARM_ARMED_HOME
|
||||||
if self._alarm.state.lower() == 'armed away':
|
if self._alarm.state.lower() == 'armed away':
|
||||||
return STATE_ALARM_ARMED_AWAY
|
return STATE_ALARM_ARMED_AWAY
|
||||||
return STATE_UNKNOWN
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_state_attributes(self):
|
def device_state_attributes(self):
|
||||||
|
|
|
@ -17,7 +17,6 @@ from homeassistant.const import (
|
||||||
CONF_HOST, CONF_NAME, CONF_PORT, STATE_ALARM_ARMED_AWAY,
|
CONF_HOST, CONF_NAME, CONF_PORT, STATE_ALARM_ARMED_AWAY,
|
||||||
STATE_ALARM_ARMED_HOME, STATE_ALARM_DISARMED)
|
STATE_ALARM_ARMED_HOME, STATE_ALARM_DISARMED)
|
||||||
|
|
||||||
|
|
||||||
REQUIREMENTS = ['concord232==0.15']
|
REQUIREMENTS = ['concord232==0.15']
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
|
@ -14,7 +14,7 @@ from homeassistant.components.alarm_control_panel import PLATFORM_SCHEMA
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_PASSWORD, CONF_USERNAME, STATE_ALARM_ARMED_AWAY,
|
CONF_PASSWORD, CONF_USERNAME, STATE_ALARM_ARMED_AWAY,
|
||||||
STATE_ALARM_ARMED_HOME, STATE_ALARM_ARMED_NIGHT, STATE_ALARM_DISARMED,
|
STATE_ALARM_ARMED_HOME, STATE_ALARM_ARMED_NIGHT, STATE_ALARM_DISARMED,
|
||||||
STATE_ALARM_ARMING, STATE_ALARM_DISARMING, STATE_UNKNOWN, CONF_NAME,
|
STATE_ALARM_ARMING, STATE_ALARM_DISARMING, CONF_NAME,
|
||||||
STATE_ALARM_ARMED_CUSTOM_BYPASS)
|
STATE_ALARM_ARMED_CUSTOM_BYPASS)
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ class TotalConnect(alarm.AlarmControlPanel):
|
||||||
self._name = name
|
self._name = name
|
||||||
self._username = username
|
self._username = username
|
||||||
self._password = password
|
self._password = password
|
||||||
self._state = STATE_UNKNOWN
|
self._state = None
|
||||||
self._client = TotalConnectClient.TotalConnectClient(
|
self._client = TotalConnectClient.TotalConnectClient(
|
||||||
username, password)
|
username, password)
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ class TotalConnect(alarm.AlarmControlPanel):
|
||||||
elif status == self._client.DISARMING:
|
elif status == self._client.DISARMING:
|
||||||
state = STATE_ALARM_DISARMING
|
state = STATE_ALARM_DISARMING
|
||||||
else:
|
else:
|
||||||
state = STATE_UNKNOWN
|
state = None
|
||||||
|
|
||||||
self._state = state
|
self._state = state
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,7 @@ import homeassistant.components.alarm_control_panel as alarm
|
||||||
from homeassistant.components.verisure import CONF_ALARM, CONF_CODE_DIGITS
|
from homeassistant.components.verisure import CONF_ALARM, CONF_CODE_DIGITS
|
||||||
from homeassistant.components.verisure import HUB as hub
|
from homeassistant.components.verisure import HUB as hub
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
STATE_ALARM_ARMED_AWAY, STATE_ALARM_ARMED_HOME, STATE_ALARM_DISARMED,
|
STATE_ALARM_ARMED_AWAY, STATE_ALARM_ARMED_HOME, STATE_ALARM_DISARMED)
|
||||||
STATE_UNKNOWN)
|
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -44,7 +43,7 @@ class VerisureAlarm(alarm.AlarmControlPanel):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
"""Initialize the Verisure alarm panel."""
|
"""Initialize the Verisure alarm panel."""
|
||||||
self._state = STATE_UNKNOWN
|
self._state = None
|
||||||
self._digits = hub.config.get(CONF_CODE_DIGITS)
|
self._digits = hub.config.get(CONF_CODE_DIGITS)
|
||||||
self._changed_by = None
|
self._changed_by = None
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,7 @@ import logging
|
||||||
import homeassistant.components.alarm_control_panel as alarm
|
import homeassistant.components.alarm_control_panel as alarm
|
||||||
from homeassistant.components.wink import DOMAIN, WinkDevice
|
from homeassistant.components.wink import DOMAIN, WinkDevice
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
STATE_ALARM_ARMED_AWAY, STATE_ALARM_ARMED_HOME, STATE_ALARM_DISARMED,
|
STATE_ALARM_ARMED_AWAY, STATE_ALARM_ARMED_HOME, STATE_ALARM_DISARMED)
|
||||||
STATE_UNKNOWN)
|
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -52,7 +51,7 @@ class WinkCameraDevice(WinkDevice, alarm.AlarmControlPanel):
|
||||||
elif wink_state == "night":
|
elif wink_state == "night":
|
||||||
state = STATE_ALARM_ARMED_HOME
|
state = STATE_ALARM_ARMED_HOME
|
||||||
else:
|
else:
|
||||||
state = STATE_UNKNOWN
|
state = None
|
||||||
return state
|
return state
|
||||||
|
|
||||||
def alarm_disarm(self, code=None):
|
def alarm_disarm(self, code=None):
|
||||||
|
|
|
@ -8,7 +8,6 @@ import logging
|
||||||
|
|
||||||
from homeassistant.components.binary_sensor import BinarySensorDevice
|
from homeassistant.components.binary_sensor import BinarySensorDevice
|
||||||
from homeassistant.components.maxcube import DATA_KEY
|
from homeassistant.components.maxcube import DATA_KEY
|
||||||
from homeassistant.const import STATE_UNKNOWN
|
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -40,7 +39,7 @@ class MaxCubeShutter(BinarySensorDevice):
|
||||||
self._sensor_type = 'window'
|
self._sensor_type = 'window'
|
||||||
self._rf_address = rf_address
|
self._rf_address = rf_address
|
||||||
self._cubehandle = handler
|
self._cubehandle = handler
|
||||||
self._state = STATE_UNKNOWN
|
self._state = None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def should_poll(self):
|
def should_poll(self):
|
||||||
|
|
|
@ -18,7 +18,7 @@ from homeassistant.helpers.config_validation import PLATFORM_SCHEMA # noqa
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_ENTITY_ID, ATTR_TEMPERATURE, SERVICE_TURN_ON, SERVICE_TURN_OFF,
|
ATTR_ENTITY_ID, ATTR_TEMPERATURE, SERVICE_TURN_ON, SERVICE_TURN_OFF,
|
||||||
STATE_ON, STATE_OFF, STATE_UNKNOWN, TEMP_CELSIUS, PRECISION_WHOLE,
|
STATE_ON, STATE_OFF, TEMP_CELSIUS, PRECISION_WHOLE,
|
||||||
PRECISION_TENTHS)
|
PRECISION_TENTHS)
|
||||||
|
|
||||||
DEFAULT_MIN_TEMP = 7
|
DEFAULT_MIN_TEMP = 7
|
||||||
|
@ -208,7 +208,7 @@ class ClimateDevice(Entity):
|
||||||
return self.current_operation
|
return self.current_operation
|
||||||
if self.is_on:
|
if self.is_on:
|
||||||
return STATE_ON
|
return STATE_ON
|
||||||
return STATE_UNKNOWN
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def precision(self):
|
def precision(self):
|
||||||
|
|
|
@ -18,7 +18,7 @@ from homeassistant.components.climate import (
|
||||||
SUPPORT_OPERATION_MODE, SUPPORT_AWAY_MODE, SUPPORT_FAN_MODE)
|
SUPPORT_OPERATION_MODE, SUPPORT_AWAY_MODE, SUPPORT_FAN_MODE)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
TEMP_CELSIUS, TEMP_FAHRENHEIT,
|
TEMP_CELSIUS, TEMP_FAHRENHEIT,
|
||||||
CONF_SCAN_INTERVAL, STATE_ON, STATE_OFF, STATE_UNKNOWN)
|
CONF_SCAN_INTERVAL, STATE_ON, STATE_OFF)
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
|
|
||||||
DEPENDENCIES = ['nest']
|
DEPENDENCIES = ['nest']
|
||||||
|
@ -163,7 +163,7 @@ class NestThermostat(ClimateDevice):
|
||||||
return self._mode
|
return self._mode
|
||||||
if self._mode == NEST_MODE_HEAT_COOL:
|
if self._mode == NEST_MODE_HEAT_COOL:
|
||||||
return STATE_AUTO
|
return STATE_AUTO
|
||||||
return STATE_UNKNOWN
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def target_temperature(self):
|
def target_temperature(self):
|
||||||
|
|
|
@ -21,7 +21,7 @@ from homeassistant.const import (
|
||||||
SERVICE_OPEN_COVER, SERVICE_CLOSE_COVER, SERVICE_SET_COVER_POSITION,
|
SERVICE_OPEN_COVER, SERVICE_CLOSE_COVER, SERVICE_SET_COVER_POSITION,
|
||||||
SERVICE_STOP_COVER, SERVICE_OPEN_COVER_TILT, SERVICE_CLOSE_COVER_TILT,
|
SERVICE_STOP_COVER, SERVICE_OPEN_COVER_TILT, SERVICE_CLOSE_COVER_TILT,
|
||||||
SERVICE_STOP_COVER_TILT, SERVICE_SET_COVER_TILT_POSITION, STATE_OPEN,
|
SERVICE_STOP_COVER_TILT, SERVICE_SET_COVER_TILT_POSITION, STATE_OPEN,
|
||||||
STATE_CLOSED, STATE_UNKNOWN, STATE_OPENING, STATE_CLOSING, ATTR_ENTITY_ID)
|
STATE_CLOSED, STATE_OPENING, STATE_CLOSING, ATTR_ENTITY_ID)
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -178,7 +178,7 @@ class CoverDevice(Entity):
|
||||||
closed = self.is_closed
|
closed = self.is_closed
|
||||||
|
|
||||||
if closed is None:
|
if closed is None:
|
||||||
return STATE_UNKNOWN
|
return None
|
||||||
|
|
||||||
return STATE_CLOSED if closed else STATE_OPEN
|
return STATE_CLOSED if closed else STATE_OPEN
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ from homeassistant.components.cover import CoverDevice, PLATFORM_SCHEMA
|
||||||
from homeassistant.helpers.event import track_utc_time_change
|
from homeassistant.helpers.event import track_utc_time_change
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_DEVICE, CONF_USERNAME, CONF_PASSWORD, CONF_ACCESS_TOKEN, CONF_NAME,
|
CONF_DEVICE, CONF_USERNAME, CONF_PASSWORD, CONF_ACCESS_TOKEN, CONF_NAME,
|
||||||
STATE_UNKNOWN, STATE_CLOSED, STATE_OPEN, CONF_COVERS)
|
STATE_CLOSED, STATE_OPEN, CONF_COVERS)
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ class GaradgetCover(CoverDevice):
|
||||||
self.obtained_token = False
|
self.obtained_token = False
|
||||||
self._username = args['username']
|
self._username = args['username']
|
||||||
self._password = args['password']
|
self._password = args['password']
|
||||||
self._state = STATE_UNKNOWN
|
self._state = None
|
||||||
self.time_in_state = None
|
self.time_in_state = None
|
||||||
self.signal = None
|
self.signal = None
|
||||||
self.sensor = None
|
self.sensor = None
|
||||||
|
@ -156,7 +156,7 @@ class GaradgetCover(CoverDevice):
|
||||||
@property
|
@property
|
||||||
def is_closed(self):
|
def is_closed(self):
|
||||||
"""Return if the cover is closed."""
|
"""Return if the cover is closed."""
|
||||||
if self._state == STATE_UNKNOWN:
|
if self._state is None:
|
||||||
return None
|
return None
|
||||||
return self._state == STATE_CLOSED
|
return self._state == STATE_CLOSED
|
||||||
|
|
||||||
|
@ -226,7 +226,7 @@ class GaradgetCover(CoverDevice):
|
||||||
try:
|
try:
|
||||||
status = self._get_variable('doorStatus')
|
status = self._get_variable('doorStatus')
|
||||||
_LOGGER.debug("Current Status: %s", status['status'])
|
_LOGGER.debug("Current Status: %s", status['status'])
|
||||||
self._state = STATES_MAP.get(status['status'], STATE_UNKNOWN)
|
self._state = STATES_MAP.get(status['status'], None)
|
||||||
self.time_in_state = status['time']
|
self.time_in_state = status['time']
|
||||||
self.signal = status['signal']
|
self.signal = status['signal']
|
||||||
self.sensor = status['sensor']
|
self.sensor = status['sensor']
|
||||||
|
|
|
@ -4,8 +4,7 @@ Support for Wink Covers.
|
||||||
For more details about this platform, please refer to the documentation at
|
For more details about this platform, please refer to the documentation at
|
||||||
https://home-assistant.io/components/cover.wink/
|
https://home-assistant.io/components/cover.wink/
|
||||||
"""
|
"""
|
||||||
from homeassistant.components.cover import CoverDevice, STATE_UNKNOWN, \
|
from homeassistant.components.cover import CoverDevice, ATTR_POSITION
|
||||||
ATTR_POSITION
|
|
||||||
from homeassistant.components.wink import WinkDevice, DOMAIN
|
from homeassistant.components.wink import WinkDevice, DOMAIN
|
||||||
|
|
||||||
DEPENDENCIES = ['wink']
|
DEPENDENCIES = ['wink']
|
||||||
|
@ -54,7 +53,7 @@ class WinkCoverDevice(WinkDevice, CoverDevice):
|
||||||
"""Return the current position of cover shutter."""
|
"""Return the current position of cover shutter."""
|
||||||
if self.wink.state() is not None:
|
if self.wink.state() is not None:
|
||||||
return int(self.wink.state()*100)
|
return int(self.wink.state()*100)
|
||||||
return STATE_UNKNOWN
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_closed(self):
|
def is_closed(self):
|
||||||
|
|
|
@ -12,8 +12,7 @@ import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components import group
|
from homeassistant.components import group
|
||||||
from homeassistant.const import (SERVICE_TURN_ON, SERVICE_TOGGLE,
|
from homeassistant.const import (SERVICE_TURN_ON, SERVICE_TOGGLE,
|
||||||
SERVICE_TURN_OFF, ATTR_ENTITY_ID,
|
SERVICE_TURN_OFF, ATTR_ENTITY_ID)
|
||||||
STATE_UNKNOWN)
|
|
||||||
from homeassistant.loader import bind_hass
|
from homeassistant.loader import bind_hass
|
||||||
from homeassistant.helpers.entity import ToggleEntity
|
from homeassistant.helpers.entity import ToggleEntity
|
||||||
from homeassistant.helpers.entity_component import EntityComponent
|
from homeassistant.helpers.entity_component import EntityComponent
|
||||||
|
@ -94,7 +93,7 @@ def is_on(hass, entity_id: str = None) -> bool:
|
||||||
"""Return if the fans are on based on the statemachine."""
|
"""Return if the fans are on based on the statemachine."""
|
||||||
entity_id = entity_id or ENTITY_ID_ALL_FANS
|
entity_id = entity_id or ENTITY_ID_ALL_FANS
|
||||||
state = hass.states.get(entity_id)
|
state = hass.states.get(entity_id)
|
||||||
return state.attributes[ATTR_SPEED] not in [SPEED_OFF, STATE_UNKNOWN]
|
return state.attributes[ATTR_SPEED] not in [SPEED_OFF, None]
|
||||||
|
|
||||||
|
|
||||||
async def async_setup(hass, config: dict):
|
async def async_setup(hass, config: dict):
|
||||||
|
@ -199,7 +198,7 @@ class FanEntity(ToggleEntity):
|
||||||
@property
|
@property
|
||||||
def is_on(self):
|
def is_on(self):
|
||||||
"""Return true if the entity is on."""
|
"""Return true if the entity is on."""
|
||||||
return self.speed not in [SPEED_OFF, STATE_UNKNOWN]
|
return self.speed not in [SPEED_OFF, None]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def speed(self) -> str:
|
def speed(self) -> str:
|
||||||
|
|
|
@ -11,7 +11,6 @@ from homeassistant.components.comfoconnect import (
|
||||||
from homeassistant.components.fan import (
|
from homeassistant.components.fan import (
|
||||||
FanEntity, SPEED_OFF, SPEED_LOW, SPEED_MEDIUM, SPEED_HIGH,
|
FanEntity, SPEED_OFF, SPEED_LOW, SPEED_MEDIUM, SPEED_HIGH,
|
||||||
SUPPORT_SET_SPEED)
|
SUPPORT_SET_SPEED)
|
||||||
from homeassistant.const import STATE_UNKNOWN
|
|
||||||
from homeassistant.helpers.dispatcher import (dispatcher_connect)
|
from homeassistant.helpers.dispatcher import (dispatcher_connect)
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
@ -79,7 +78,7 @@ class ComfoConnectFan(FanEntity):
|
||||||
speed = self._ccb.data[SENSOR_FAN_SPEED_MODE]
|
speed = self._ccb.data[SENSOR_FAN_SPEED_MODE]
|
||||||
return SPEED_MAPPING[speed]
|
return SPEED_MAPPING[speed]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return STATE_UNKNOWN
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def speed_list(self):
|
def speed_list(self):
|
||||||
|
|
|
@ -7,7 +7,7 @@ https://home-assistant.io/components/fan.wink/
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from homeassistant.components.fan import (
|
from homeassistant.components.fan import (
|
||||||
SPEED_HIGH, SPEED_LOW, SPEED_MEDIUM, STATE_UNKNOWN, SUPPORT_DIRECTION,
|
SPEED_HIGH, SPEED_LOW, SPEED_MEDIUM, SUPPORT_DIRECTION,
|
||||||
SUPPORT_SET_SPEED, FanEntity)
|
SUPPORT_SET_SPEED, FanEntity)
|
||||||
from homeassistant.components.wink import DOMAIN, WinkDevice
|
from homeassistant.components.wink import DOMAIN, WinkDevice
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ class WinkFanDevice(WinkDevice, FanEntity):
|
||||||
return SPEED_MEDIUM
|
return SPEED_MEDIUM
|
||||||
if SPEED_HIGH == current_wink_speed:
|
if SPEED_HIGH == current_wink_speed:
|
||||||
return SPEED_HIGH
|
return SPEED_HIGH
|
||||||
return STATE_UNKNOWN
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def current_direction(self):
|
def current_direction(self):
|
||||||
|
|
|
@ -15,7 +15,7 @@ import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers import discovery
|
from homeassistant.helpers import discovery
|
||||||
from homeassistant.components.media_player import DOMAIN as MEDIA_PLAYER
|
from homeassistant.components.media_player import DOMAIN as MEDIA_PLAYER
|
||||||
from homeassistant.components.switch import DOMAIN as SWITCH
|
from homeassistant.components.switch import DOMAIN as SWITCH
|
||||||
from homeassistant.const import (EVENT_HOMEASSISTANT_START, STATE_UNKNOWN,
|
from homeassistant.const import (EVENT_HOMEASSISTANT_START,
|
||||||
EVENT_HOMEASSISTANT_STOP, STATE_ON,
|
EVENT_HOMEASSISTANT_STOP, STATE_ON,
|
||||||
STATE_OFF, CONF_DEVICES, CONF_PLATFORM,
|
STATE_OFF, CONF_DEVICES, CONF_PLATFORM,
|
||||||
STATE_PLAYING, STATE_IDLE,
|
STATE_PLAYING, STATE_IDLE,
|
||||||
|
@ -324,7 +324,7 @@ class CecDevice(Entity):
|
||||||
"""Initialize the device."""
|
"""Initialize the device."""
|
||||||
self._device = device
|
self._device = device
|
||||||
self._icon = None
|
self._icon = None
|
||||||
self._state = STATE_UNKNOWN
|
self._state = None
|
||||||
self._logical_address = logical
|
self._logical_address = logical
|
||||||
self.entity_id = "%s.%d" % (DOMAIN, self._logical_address)
|
self.entity_id = "%s.%d" % (DOMAIN, self._logical_address)
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,8 @@ import logging
|
||||||
from pyhap.const import CATEGORY_DOOR_LOCK
|
from pyhap.const import CATEGORY_DOOR_LOCK
|
||||||
|
|
||||||
from homeassistant.components.lock import (
|
from homeassistant.components.lock import (
|
||||||
ATTR_ENTITY_ID, DOMAIN, STATE_LOCKED, STATE_UNLOCKED, STATE_UNKNOWN)
|
ATTR_ENTITY_ID, DOMAIN, STATE_LOCKED, STATE_UNLOCKED)
|
||||||
from homeassistant.const import ATTR_CODE
|
from homeassistant.const import ATTR_CODE, STATE_UNKNOWN
|
||||||
|
|
||||||
from . import TYPES
|
from . import TYPES
|
||||||
from .accessories import HomeAccessory
|
from .accessories import HomeAccessory
|
||||||
|
|
|
@ -13,7 +13,7 @@ import voluptuous as vol
|
||||||
|
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.core import split_entity_id, callback
|
from homeassistant.core import split_entity_id, callback
|
||||||
from homeassistant.const import STATE_UNKNOWN, CONF_REGION
|
from homeassistant.const import CONF_REGION
|
||||||
from homeassistant.components.image_processing import (
|
from homeassistant.components.image_processing import (
|
||||||
PLATFORM_SCHEMA, ImageProcessingEntity, CONF_CONFIDENCE, CONF_SOURCE,
|
PLATFORM_SCHEMA, ImageProcessingEntity, CONF_CONFIDENCE, CONF_SOURCE,
|
||||||
CONF_ENTITY_ID, CONF_NAME, ATTR_ENTITY_ID, ATTR_CONFIDENCE)
|
CONF_ENTITY_ID, CONF_NAME, ATTR_ENTITY_ID, ATTR_CONFIDENCE)
|
||||||
|
@ -82,7 +82,7 @@ class ImageProcessingAlprEntity(ImageProcessingEntity):
|
||||||
def state(self):
|
def state(self):
|
||||||
"""Return the state of the entity."""
|
"""Return the state of the entity."""
|
||||||
confidence = 0
|
confidence = 0
|
||||||
plate = STATE_UNKNOWN
|
plate = None
|
||||||
|
|
||||||
# search high plate
|
# search high plate
|
||||||
for i_pl, i_co in self.plates.items():
|
for i_pl, i_co in self.plates.items():
|
||||||
|
|
|
@ -17,7 +17,7 @@ from homeassistant.helpers.config_validation import PLATFORM_SCHEMA # noqa
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_CODE, ATTR_CODE_FORMAT, ATTR_ENTITY_ID, STATE_LOCKED, STATE_UNLOCKED,
|
ATTR_CODE, ATTR_CODE_FORMAT, ATTR_ENTITY_ID, STATE_LOCKED, STATE_UNLOCKED,
|
||||||
STATE_UNKNOWN, SERVICE_LOCK, SERVICE_UNLOCK, SERVICE_OPEN)
|
SERVICE_LOCK, SERVICE_UNLOCK, SERVICE_OPEN)
|
||||||
from homeassistant.components import group
|
from homeassistant.components import group
|
||||||
|
|
||||||
ATTR_CHANGED_BY = 'changed_by'
|
ATTR_CHANGED_BY = 'changed_by'
|
||||||
|
@ -150,5 +150,5 @@ class LockDevice(Entity):
|
||||||
"""Return the state."""
|
"""Return the state."""
|
||||||
locked = self.is_locked
|
locked = self.is_locked
|
||||||
if locked is None:
|
if locked is None:
|
||||||
return STATE_UNKNOWN
|
return None
|
||||||
return STATE_LOCKED if locked else STATE_UNLOCKED
|
return STATE_LOCKED if locked else STATE_UNLOCKED
|
||||||
|
|
|
@ -12,7 +12,7 @@ from homeassistant.components.verisure import (
|
||||||
CONF_LOCKS, CONF_DEFAULT_LOCK_CODE, CONF_CODE_DIGITS)
|
CONF_LOCKS, CONF_DEFAULT_LOCK_CODE, CONF_CODE_DIGITS)
|
||||||
from homeassistant.components.lock import LockDevice
|
from homeassistant.components.lock import LockDevice
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_CODE, STATE_LOCKED, STATE_UNKNOWN, STATE_UNLOCKED)
|
ATTR_CODE, STATE_LOCKED, STATE_UNLOCKED)
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ class VerisureDoorlock(LockDevice):
|
||||||
def __init__(self, device_label):
|
def __init__(self, device_label):
|
||||||
"""Initialize the Verisure lock."""
|
"""Initialize the Verisure lock."""
|
||||||
self._device_label = device_label
|
self._device_label = device_label
|
||||||
self._state = STATE_UNKNOWN
|
self._state = None
|
||||||
self._digits = hub.config.get(CONF_CODE_DIGITS)
|
self._digits = hub.config.get(CONF_CODE_DIGITS)
|
||||||
self._changed_by = None
|
self._changed_by = None
|
||||||
self._change_timestamp = 0
|
self._change_timestamp = 0
|
||||||
|
@ -80,7 +80,7 @@ class VerisureDoorlock(LockDevice):
|
||||||
"$.doorLockStatusList[?(@.deviceLabel=='%s')].lockedState",
|
"$.doorLockStatusList[?(@.deviceLabel=='%s')].lockedState",
|
||||||
self._device_label)
|
self._device_label)
|
||||||
if status == 'UNLOCKED':
|
if status == 'UNLOCKED':
|
||||||
self._state = STATE_UNLOCKED
|
self._state = None
|
||||||
elif status == 'LOCKED':
|
elif status == 'LOCKED':
|
||||||
self._state = STATE_LOCKED
|
self._state = STATE_LOCKED
|
||||||
elif status != 'PENDING':
|
elif status != 'PENDING':
|
||||||
|
@ -96,7 +96,7 @@ class VerisureDoorlock(LockDevice):
|
||||||
|
|
||||||
def unlock(self, **kwargs):
|
def unlock(self, **kwargs):
|
||||||
"""Send unlock command."""
|
"""Send unlock command."""
|
||||||
if self._state == STATE_UNLOCKED:
|
if self._state is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
code = kwargs.get(ATTR_CODE, self._default_lock_code)
|
code = kwargs.get(ATTR_CODE, self._default_lock_code)
|
||||||
|
|
|
@ -27,7 +27,7 @@ from homeassistant.const import (
|
||||||
SERVICE_MEDIA_SEEK, SERVICE_MEDIA_STOP, SERVICE_SHUFFLE_SET,
|
SERVICE_MEDIA_SEEK, SERVICE_MEDIA_STOP, SERVICE_SHUFFLE_SET,
|
||||||
SERVICE_TOGGLE, SERVICE_TURN_OFF, SERVICE_TURN_ON, SERVICE_VOLUME_DOWN,
|
SERVICE_TOGGLE, SERVICE_TURN_OFF, SERVICE_TURN_ON, SERVICE_VOLUME_DOWN,
|
||||||
SERVICE_VOLUME_MUTE, SERVICE_VOLUME_SET, SERVICE_VOLUME_UP, STATE_IDLE,
|
SERVICE_VOLUME_MUTE, SERVICE_VOLUME_SET, SERVICE_VOLUME_UP, STATE_IDLE,
|
||||||
STATE_OFF, STATE_PLAYING, STATE_UNKNOWN)
|
STATE_OFF, STATE_PLAYING)
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.config_validation import PLATFORM_SCHEMA # noqa
|
from homeassistant.helpers.config_validation import PLATFORM_SCHEMA # noqa
|
||||||
|
@ -317,7 +317,7 @@ class MediaPlayerDevice(Entity):
|
||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self):
|
||||||
"""State of the player."""
|
"""State of the player."""
|
||||||
return STATE_UNKNOWN
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def access_token(self):
|
def access_token(self):
|
||||||
|
|
|
@ -13,7 +13,7 @@ from homeassistant.components.media_player import (
|
||||||
SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_SET, MediaPlayerDevice)
|
SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_SET, MediaPlayerDevice)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_HOST, CONF_NAME, CONF_PORT, EVENT_HOMEASSISTANT_STOP, STATE_OFF,
|
CONF_HOST, CONF_NAME, CONF_PORT, EVENT_HOMEASSISTANT_STOP, STATE_OFF,
|
||||||
STATE_ON, STATE_UNKNOWN)
|
STATE_ON)
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
REQUIREMENTS = ['anthemav==1.1.8']
|
REQUIREMENTS = ['anthemav==1.1.8']
|
||||||
|
@ -100,7 +100,7 @@ class AnthemAVR(MediaPlayerDevice):
|
||||||
return STATE_ON
|
return STATE_ON
|
||||||
if pwrstate is False:
|
if pwrstate is False:
|
||||||
return STATE_OFF
|
return STATE_OFF
|
||||||
return STATE_UNKNOWN
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_volume_muted(self):
|
def is_volume_muted(self):
|
||||||
|
|
|
@ -15,7 +15,7 @@ from homeassistant.components.media_player import (
|
||||||
SUPPORT_VOLUME_STEP, MediaPlayerDevice)
|
SUPPORT_VOLUME_STEP, MediaPlayerDevice)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_HOST, CONF_NAME, CONF_PASSWORD, CONF_PORT, CONF_TIMEOUT,
|
CONF_HOST, CONF_NAME, CONF_PASSWORD, CONF_PORT, CONF_TIMEOUT,
|
||||||
CONF_USERNAME, STATE_OFF, STATE_ON, STATE_UNKNOWN)
|
CONF_USERNAME, STATE_OFF, STATE_ON)
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
REQUIREMENTS = ['sharp_aquos_rc==0.3.2']
|
REQUIREMENTS = ['sharp_aquos_rc==0.3.2']
|
||||||
|
@ -113,7 +113,7 @@ class SharpAquosTVDevice(MediaPlayerDevice):
|
||||||
self._name = name
|
self._name = name
|
||||||
# Assume that the TV is not muted
|
# Assume that the TV is not muted
|
||||||
self._muted = False
|
self._muted = False
|
||||||
self._state = STATE_UNKNOWN
|
self._state = None
|
||||||
self._remote = remote
|
self._remote = remote
|
||||||
self._volume = 0
|
self._volume = 0
|
||||||
self._source = None
|
self._source = None
|
||||||
|
|
|
@ -14,8 +14,7 @@ from homeassistant.components.media_player import (
|
||||||
SUPPORT_PREVIOUS_TRACK, SUPPORT_SELECT_SOURCE, SUPPORT_STOP,
|
SUPPORT_PREVIOUS_TRACK, SUPPORT_SELECT_SOURCE, SUPPORT_STOP,
|
||||||
SUPPORT_TURN_OFF, SUPPORT_TURN_ON, SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_SET,
|
SUPPORT_TURN_OFF, SUPPORT_TURN_ON, SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_SET,
|
||||||
MediaPlayerDevice)
|
MediaPlayerDevice)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import CONF_HOST, CONF_NAME, STATE_OFF, STATE_ON
|
||||||
CONF_HOST, CONF_NAME, STATE_OFF, STATE_ON, STATE_UNKNOWN)
|
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
@ -169,7 +168,7 @@ class DenonDevice(MediaPlayerDevice):
|
||||||
if self._pwstate == 'PWON':
|
if self._pwstate == 'PWON':
|
||||||
return STATE_ON
|
return STATE_ON
|
||||||
|
|
||||||
return STATE_UNKNOWN
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def volume_level(self):
|
def volume_level(self):
|
||||||
|
|
|
@ -18,7 +18,7 @@ from homeassistant.components.media_player import (
|
||||||
MediaPlayerDevice)
|
MediaPlayerDevice)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_ACCESS_TOKEN, CONF_HOST, CONF_NAME, STATE_OFF, STATE_PAUSED,
|
CONF_ACCESS_TOKEN, CONF_HOST, CONF_NAME, STATE_OFF, STATE_PAUSED,
|
||||||
STATE_PLAYING, STATE_UNKNOWN)
|
STATE_PLAYING)
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
REQUIREMENTS = ['pylgnetcast-homeassistant==0.2.0.dev0']
|
REQUIREMENTS = ['pylgnetcast-homeassistant==0.2.0.dev0']
|
||||||
|
@ -68,7 +68,7 @@ class LgTVDevice(MediaPlayerDevice):
|
||||||
self._volume = 0
|
self._volume = 0
|
||||||
self._channel_name = ''
|
self._channel_name = ''
|
||||||
self._program_name = ''
|
self._program_name = ''
|
||||||
self._state = STATE_UNKNOWN
|
self._state = None
|
||||||
self._sources = {}
|
self._sources = {}
|
||||||
self._source_names = []
|
self._source_names = []
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ from homeassistant.components.media_player import (
|
||||||
PLATFORM_SCHEMA, SUPPORT_PAUSE, SUPPORT_PLAY, SUPPORT_STOP,
|
PLATFORM_SCHEMA, SUPPORT_PAUSE, SUPPORT_PLAY, SUPPORT_STOP,
|
||||||
SUPPORT_TURN_OFF, SUPPORT_TURN_ON, MediaPlayerDevice)
|
SUPPORT_TURN_OFF, SUPPORT_TURN_ON, MediaPlayerDevice)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_HOST, CONF_NAME, STATE_IDLE, STATE_OFF, STATE_PLAYING, STATE_UNKNOWN)
|
CONF_HOST, CONF_NAME, STATE_IDLE, STATE_OFF, STATE_PLAYING)
|
||||||
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
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ class PanasonicBluRay(MediaPlayerDevice):
|
||||||
state = self._device.get_play_status()
|
state = self._device.get_play_status()
|
||||||
|
|
||||||
if state[0] == 'error':
|
if state[0] == 'error':
|
||||||
self._state = STATE_UNKNOWN
|
self._state = None
|
||||||
elif state[0] in ['off', 'standby']:
|
elif state[0] in ['off', 'standby']:
|
||||||
# We map both of these to off. If it's really off we can't
|
# We map both of these to off. If it's really off we can't
|
||||||
# turn it on, but from standby we can go to idle by pressing
|
# turn it on, but from standby we can go to idle by pressing
|
||||||
|
|
|
@ -14,8 +14,7 @@ from homeassistant.components.media_player import (
|
||||||
SUPPORT_TURN_OFF, SUPPORT_TURN_ON, SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_SET,
|
SUPPORT_TURN_OFF, SUPPORT_TURN_ON, SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_SET,
|
||||||
SUPPORT_VOLUME_STEP, MediaPlayerDevice)
|
SUPPORT_VOLUME_STEP, MediaPlayerDevice)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_HOST, CONF_MAC, CONF_NAME, CONF_PORT, STATE_OFF, STATE_ON,
|
CONF_HOST, CONF_MAC, CONF_NAME, CONF_PORT, STATE_OFF, STATE_ON)
|
||||||
STATE_UNKNOWN)
|
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
REQUIREMENTS = ['panasonic_viera==0.3.1', 'wakeonlan==1.1.6']
|
REQUIREMENTS = ['panasonic_viera==0.3.1', 'wakeonlan==1.1.6']
|
||||||
|
@ -81,7 +80,7 @@ class PanasonicVieraTVDevice(MediaPlayerDevice):
|
||||||
self._uuid = uuid
|
self._uuid = uuid
|
||||||
self._muted = False
|
self._muted = False
|
||||||
self._playing = True
|
self._playing = True
|
||||||
self._state = STATE_UNKNOWN
|
self._state = None
|
||||||
self._remote = remote
|
self._remote = remote
|
||||||
self._volume = 0
|
self._volume = 0
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ from homeassistant.components.media_player import (
|
||||||
SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_SET, SUPPORT_VOLUME_STEP,
|
SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_SET, SUPPORT_VOLUME_STEP,
|
||||||
MediaPlayerDevice)
|
MediaPlayerDevice)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_API_VERSION, CONF_HOST, CONF_NAME, STATE_OFF, STATE_ON, STATE_UNKNOWN)
|
CONF_API_VERSION, CONF_HOST, CONF_NAME, STATE_OFF, STATE_ON)
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.script import Script
|
from homeassistant.helpers.script import Script
|
||||||
from homeassistant.util import Throttle
|
from homeassistant.util import Throttle
|
||||||
|
@ -70,7 +70,7 @@ class PhilipsTV(MediaPlayerDevice):
|
||||||
"""Initialize the Philips TV."""
|
"""Initialize the Philips TV."""
|
||||||
self._tv = tv
|
self._tv = tv
|
||||||
self._name = name
|
self._name = name
|
||||||
self._state = STATE_UNKNOWN
|
self._state = None
|
||||||
self._min_volume = None
|
self._min_volume = None
|
||||||
self._max_volume = None
|
self._max_volume = None
|
||||||
self._volume = None
|
self._volume = None
|
||||||
|
|
|
@ -14,8 +14,7 @@ from homeassistant.components.media_player import (
|
||||||
SUPPORT_TURN_OFF, SUPPORT_TURN_ON, SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_SET,
|
SUPPORT_TURN_OFF, SUPPORT_TURN_ON, SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_SET,
|
||||||
MediaPlayerDevice)
|
MediaPlayerDevice)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_HOST, CONF_NAME, CONF_PORT, CONF_TIMEOUT, STATE_OFF, STATE_ON,
|
CONF_HOST, CONF_NAME, CONF_PORT, CONF_TIMEOUT, STATE_OFF, STATE_ON)
|
||||||
STATE_UNKNOWN)
|
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
@ -157,7 +156,7 @@ class PioneerDevice(MediaPlayerDevice):
|
||||||
if self._pwstate == "PWR0":
|
if self._pwstate == "PWR0":
|
||||||
return STATE_ON
|
return STATE_ON
|
||||||
|
|
||||||
return STATE_UNKNOWN
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def volume_level(self):
|
def volume_level(self):
|
||||||
|
|
|
@ -11,8 +11,8 @@ from homeassistant.components.media_player import (
|
||||||
MEDIA_TYPE_MOVIE, SUPPORT_NEXT_TRACK, SUPPORT_PLAY,
|
MEDIA_TYPE_MOVIE, SUPPORT_NEXT_TRACK, SUPPORT_PLAY,
|
||||||
SUPPORT_PLAY_MEDIA, SUPPORT_PREVIOUS_TRACK, SUPPORT_SELECT_SOURCE,
|
SUPPORT_PLAY_MEDIA, SUPPORT_PREVIOUS_TRACK, SUPPORT_SELECT_SOURCE,
|
||||||
SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_SET, MediaPlayerDevice)
|
SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_SET, MediaPlayerDevice)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (CONF_HOST, STATE_HOME, STATE_IDLE,
|
||||||
CONF_HOST, STATE_HOME, STATE_IDLE, STATE_PLAYING, STATE_UNKNOWN)
|
STATE_PLAYING)
|
||||||
|
|
||||||
DEPENDENCIES = ['roku']
|
DEPENDENCIES = ['roku']
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ class RokuDevice(MediaPlayerDevice):
|
||||||
def state(self):
|
def state(self):
|
||||||
"""Return the state of the device."""
|
"""Return the state of the device."""
|
||||||
if self.current_app is None:
|
if self.current_app is None:
|
||||||
return STATE_UNKNOWN
|
return None
|
||||||
|
|
||||||
if (self.current_app.name == "Power Saver" or
|
if (self.current_app.name == "Power Saver" or
|
||||||
self.current_app.is_screensaver):
|
self.current_app.is_screensaver):
|
||||||
|
@ -93,7 +93,7 @@ class RokuDevice(MediaPlayerDevice):
|
||||||
if self.current_app.name is not None:
|
if self.current_app.name is not None:
|
||||||
return STATE_PLAYING
|
return STATE_PLAYING
|
||||||
|
|
||||||
return STATE_UNKNOWN
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_features(self):
|
def supported_features(self):
|
||||||
|
|
|
@ -16,7 +16,7 @@ from homeassistant.components.media_player import (
|
||||||
SUPPORT_SELECT_SOURCE, SUPPORT_SHUFFLE_SET, SUPPORT_VOLUME_SET,
|
SUPPORT_SELECT_SOURCE, SUPPORT_SHUFFLE_SET, SUPPORT_VOLUME_SET,
|
||||||
MediaPlayerDevice)
|
MediaPlayerDevice)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_NAME, STATE_IDLE, STATE_PAUSED, STATE_PLAYING, STATE_UNKNOWN)
|
CONF_NAME, STATE_IDLE, STATE_PAUSED, STATE_PLAYING)
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ class SpotifyMediaPlayer(MediaPlayerDevice):
|
||||||
self._artist = None
|
self._artist = None
|
||||||
self._uri = None
|
self._uri = None
|
||||||
self._image_url = None
|
self._image_url = None
|
||||||
self._state = STATE_UNKNOWN
|
self._state = None
|
||||||
self._current_device = None
|
self._current_device = None
|
||||||
self._devices = {}
|
self._devices = {}
|
||||||
self._volume = None
|
self._volume = None
|
||||||
|
|
|
@ -21,7 +21,7 @@ from homeassistant.components.media_player import (
|
||||||
SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_SET, MediaPlayerDevice)
|
SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_SET, MediaPlayerDevice)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_COMMAND, CONF_HOST, CONF_PASSWORD, CONF_PORT, CONF_USERNAME,
|
ATTR_COMMAND, CONF_HOST, CONF_PASSWORD, CONF_PORT, CONF_USERNAME,
|
||||||
STATE_IDLE, STATE_OFF, STATE_PAUSED, STATE_PLAYING, STATE_UNKNOWN)
|
STATE_IDLE, STATE_OFF, STATE_PAUSED, STATE_PLAYING)
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
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
|
||||||
|
@ -242,7 +242,7 @@ class SqueezeBoxDevice(MediaPlayerDevice):
|
||||||
return STATE_PLAYING
|
return STATE_PLAYING
|
||||||
if self._status['mode'] == 'stop':
|
if self._status['mode'] == 'stop':
|
||||||
return STATE_IDLE
|
return STATE_IDLE
|
||||||
return STATE_UNKNOWN
|
return None
|
||||||
|
|
||||||
def async_query(self, *parameters):
|
def async_query(self, *parameters):
|
||||||
"""Send a command to the LMS.
|
"""Send a command to the LMS.
|
||||||
|
|
|
@ -16,8 +16,7 @@ from homeassistant.components.media_player import (
|
||||||
SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_SET, SUPPORT_VOLUME_STEP,
|
SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_SET, SUPPORT_VOLUME_STEP,
|
||||||
MediaPlayerDevice)
|
MediaPlayerDevice)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_ACCESS_TOKEN, CONF_HOST, CONF_NAME, STATE_OFF, STATE_ON,
|
CONF_ACCESS_TOKEN, CONF_HOST, CONF_NAME, STATE_OFF, STATE_ON)
|
||||||
STATE_UNKNOWN)
|
|
||||||
from homeassistant.helpers import config_validation as cv
|
from homeassistant.helpers import config_validation as cv
|
||||||
|
|
||||||
REQUIREMENTS = ['pyvizio==0.0.4']
|
REQUIREMENTS = ['pyvizio==0.0.4']
|
||||||
|
@ -82,7 +81,7 @@ class VizioDevice(MediaPlayerDevice):
|
||||||
import pyvizio
|
import pyvizio
|
||||||
self._device = pyvizio.Vizio(DEVICE_ID, host, DEFAULT_NAME, token)
|
self._device = pyvizio.Vizio(DEVICE_ID, host, DEFAULT_NAME, token)
|
||||||
self._name = name
|
self._name = name
|
||||||
self._state = STATE_UNKNOWN
|
self._state = None
|
||||||
self._volume_level = None
|
self._volume_level = None
|
||||||
self._volume_step = volume_step
|
self._volume_step = volume_step
|
||||||
self._current_input = None
|
self._current_input = None
|
||||||
|
@ -93,7 +92,7 @@ class VizioDevice(MediaPlayerDevice):
|
||||||
"""Retrieve latest state of the TV."""
|
"""Retrieve latest state of the TV."""
|
||||||
is_on = self._device.get_power_state()
|
is_on = self._device.get_power_state()
|
||||||
if is_on is None:
|
if is_on is None:
|
||||||
self._state = STATE_UNKNOWN
|
self._state = None
|
||||||
return
|
return
|
||||||
if is_on is False:
|
if is_on is False:
|
||||||
self._state = STATE_OFF
|
self._state = STATE_OFF
|
||||||
|
|
|
@ -20,7 +20,7 @@ from homeassistant.components.media_player import (
|
||||||
SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_STEP, MediaPlayerDevice)
|
SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_STEP, MediaPlayerDevice)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_CUSTOMIZE, CONF_FILENAME, CONF_HOST, CONF_NAME, CONF_TIMEOUT,
|
CONF_CUSTOMIZE, CONF_FILENAME, CONF_HOST, CONF_NAME, CONF_TIMEOUT,
|
||||||
STATE_OFF, STATE_PAUSED, STATE_PLAYING, STATE_UNKNOWN)
|
STATE_OFF, STATE_PAUSED, STATE_PLAYING)
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.script import Script
|
from homeassistant.helpers.script import Script
|
||||||
|
|
||||||
|
@ -168,7 +168,7 @@ class LgWebOSDevice(MediaPlayerDevice):
|
||||||
self._volume = 0
|
self._volume = 0
|
||||||
self._current_source = None
|
self._current_source = None
|
||||||
self._current_source_id = None
|
self._current_source_id = None
|
||||||
self._state = STATE_UNKNOWN
|
self._state = None
|
||||||
self._source_list = {}
|
self._source_list = {}
|
||||||
self._app_list = {}
|
self._app_list = {}
|
||||||
self._channel = None
|
self._channel = None
|
||||||
|
@ -181,7 +181,7 @@ class LgWebOSDevice(MediaPlayerDevice):
|
||||||
current_input = self._client.get_input()
|
current_input = self._client.get_input()
|
||||||
if current_input is not None:
|
if current_input is not None:
|
||||||
self._current_source_id = current_input
|
self._current_source_id = current_input
|
||||||
if self._state in (STATE_UNKNOWN, STATE_OFF):
|
if self._state in (None, STATE_OFF):
|
||||||
self._state = STATE_PLAYING
|
self._state = STATE_PLAYING
|
||||||
else:
|
else:
|
||||||
self._state = STATE_OFF
|
self._state = STATE_OFF
|
||||||
|
|
|
@ -15,7 +15,7 @@ from homeassistant.components import mqtt
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_CODE, CONF_DEVICE, CONF_NAME, STATE_ALARM_ARMED_AWAY,
|
CONF_CODE, CONF_DEVICE, CONF_NAME, STATE_ALARM_ARMED_AWAY,
|
||||||
STATE_ALARM_ARMED_HOME, STATE_ALARM_DISARMED, STATE_ALARM_PENDING,
|
STATE_ALARM_ARMED_HOME, STATE_ALARM_DISARMED, STATE_ALARM_PENDING,
|
||||||
STATE_ALARM_TRIGGERED, STATE_UNKNOWN)
|
STATE_ALARM_TRIGGERED)
|
||||||
from homeassistant.components.mqtt import (
|
from homeassistant.components.mqtt import (
|
||||||
ATTR_DISCOVERY_HASH, CONF_COMMAND_TOPIC, CONF_QOS, CONF_RETAIN,
|
ATTR_DISCOVERY_HASH, CONF_COMMAND_TOPIC, CONF_QOS, CONF_RETAIN,
|
||||||
CONF_STATE_TOPIC, MqttAttributes, MqttAvailability, MqttDiscoveryUpdate,
|
CONF_STATE_TOPIC, MqttAttributes, MqttAvailability, MqttDiscoveryUpdate,
|
||||||
|
@ -90,7 +90,7 @@ class MqttAlarm(MqttAttributes, MqttAvailability, MqttDiscoveryUpdate,
|
||||||
|
|
||||||
def __init__(self, config, discovery_hash):
|
def __init__(self, config, discovery_hash):
|
||||||
"""Init the MQTT Alarm Control Panel."""
|
"""Init the MQTT Alarm Control Panel."""
|
||||||
self._state = STATE_UNKNOWN
|
self._state = None
|
||||||
self._config = config
|
self._config = config
|
||||||
self._unique_id = config.get(CONF_UNIQUE_ID)
|
self._unique_id = config.get(CONF_UNIQUE_ID)
|
||||||
self._sub_state = None
|
self._sub_state = None
|
||||||
|
|
|
@ -20,7 +20,7 @@ from homeassistant.components.mqtt.discovery import (
|
||||||
MQTT_DISCOVERY_NEW, clear_discovery_hash)
|
MQTT_DISCOVERY_NEW, clear_discovery_hash)
|
||||||
from homeassistant.components.sensor import DEVICE_CLASSES_SCHEMA
|
from homeassistant.components.sensor import DEVICE_CLASSES_SCHEMA
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_FORCE_UPDATE, CONF_NAME, CONF_VALUE_TEMPLATE, STATE_UNKNOWN,
|
CONF_FORCE_UPDATE, CONF_NAME, CONF_VALUE_TEMPLATE,
|
||||||
CONF_UNIT_OF_MEASUREMENT, CONF_ICON, CONF_DEVICE_CLASS, CONF_DEVICE)
|
CONF_UNIT_OF_MEASUREMENT, CONF_ICON, CONF_DEVICE_CLASS, CONF_DEVICE)
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
from homeassistant.components import mqtt
|
from homeassistant.components import mqtt
|
||||||
|
@ -95,7 +95,7 @@ class MqttSensor(MqttAttributes, MqttAvailability, MqttDiscoveryUpdate,
|
||||||
"""Initialize the sensor."""
|
"""Initialize the sensor."""
|
||||||
self._config = config
|
self._config = config
|
||||||
self._unique_id = config.get(CONF_UNIQUE_ID)
|
self._unique_id = config.get(CONF_UNIQUE_ID)
|
||||||
self._state = STATE_UNKNOWN
|
self._state = None
|
||||||
self._sub_state = None
|
self._sub_state = None
|
||||||
self._expiration_trigger = None
|
self._expiration_trigger = None
|
||||||
self._attributes = None
|
self._attributes = None
|
||||||
|
@ -188,7 +188,7 @@ class MqttSensor(MqttAttributes, MqttAvailability, MqttDiscoveryUpdate,
|
||||||
def value_is_expired(self, *_):
|
def value_is_expired(self, *_):
|
||||||
"""Triggered when value is expired."""
|
"""Triggered when value is expired."""
|
||||||
self._expiration_trigger = None
|
self._expiration_trigger = None
|
||||||
self._state = STATE_UNKNOWN
|
self._state = None
|
||||||
self.async_schedule_update_ha_state()
|
self.async_schedule_update_ha_state()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
@ -167,7 +167,7 @@ class Plant(Entity):
|
||||||
for reading, entity_id in config['sensors'].items():
|
for reading, entity_id in config['sensors'].items():
|
||||||
self._sensormap[entity_id] = reading
|
self._sensormap[entity_id] = reading
|
||||||
self._readingmap[reading] = entity_id
|
self._readingmap[reading] = entity_id
|
||||||
self._state = STATE_UNKNOWN
|
self._state = None
|
||||||
self._name = name
|
self._name = name
|
||||||
self._battery = None
|
self._battery = None
|
||||||
self._moisture = None
|
self._moisture = None
|
||||||
|
|
|
@ -9,7 +9,7 @@ import logging
|
||||||
|
|
||||||
from homeassistant.components.amcrest import DATA_AMCREST, SENSORS
|
from homeassistant.components.amcrest import DATA_AMCREST, SENSORS
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
from homeassistant.const import CONF_NAME, CONF_SENSORS, STATE_UNKNOWN
|
from homeassistant.const import CONF_NAME, CONF_SENSORS
|
||||||
|
|
||||||
DEPENDENCIES = ['amcrest']
|
DEPENDENCIES = ['amcrest']
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ class AmcrestSensor(Entity):
|
||||||
self._name = '{0}_{1}'.format(name,
|
self._name = '{0}_{1}'.format(name,
|
||||||
SENSORS.get(self._sensor_type)[0])
|
SENSORS.get(self._sensor_type)[0])
|
||||||
self._icon = 'mdi:{}'.format(SENSORS.get(self._sensor_type)[2])
|
self._icon = 'mdi:{}'.format(SENSORS.get(self._sensor_type)[2])
|
||||||
self._state = STATE_UNKNOWN
|
self._state = None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
|
|
|
@ -13,7 +13,7 @@ import voluptuous as vol
|
||||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_UNIT_OF_MEASUREMENT, CONF_VALUE_TEMPLATE, CONF_RESOURCE,
|
CONF_UNIT_OF_MEASUREMENT, CONF_VALUE_TEMPLATE, CONF_RESOURCE,
|
||||||
CONF_MONITORED_VARIABLES, CONF_NAME, STATE_UNKNOWN)
|
CONF_MONITORED_VARIABLES, CONF_NAME)
|
||||||
from homeassistant.exceptions import TemplateError
|
from homeassistant.exceptions import TemplateError
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
from homeassistant.util import Throttle
|
from homeassistant.util import Throttle
|
||||||
|
@ -116,7 +116,7 @@ class ArestSensor(Entity):
|
||||||
self._name = '{} {}'.format(location.title(), name.title())
|
self._name = '{} {}'.format(location.title(), name.title())
|
||||||
self._variable = variable
|
self._variable = variable
|
||||||
self._pin = pin
|
self._pin = pin
|
||||||
self._state = STATE_UNKNOWN
|
self._state = None
|
||||||
self._unit_of_measurement = unit_of_measurement
|
self._unit_of_measurement = unit_of_measurement
|
||||||
self._renderer = renderer
|
self._renderer = renderer
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ class ArestSensor(Entity):
|
||||||
return values['error']
|
return values['error']
|
||||||
|
|
||||||
value = self._renderer(
|
value = self._renderer(
|
||||||
values.get('value', values.get(self._variable, STATE_UNKNOWN)))
|
values.get('value', values.get(self._variable, None)))
|
||||||
return value
|
return value
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
|
|
|
@ -15,7 +15,7 @@ import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_ATTRIBUTION, CONF_NAME, CONF_OFFSET, STATE_UNKNOWN)
|
ATTR_ATTRIBUTION, CONF_NAME, CONF_OFFSET)
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
|
@ -120,7 +120,7 @@ class ComedHourlyPricingSensor(Entity):
|
||||||
float(data[0]['price']) + self.offset, 2)
|
float(data[0]['price']) + self.offset, 2)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
self._state = STATE_UNKNOWN
|
self._state = None
|
||||||
|
|
||||||
except (asyncio.TimeoutError, aiohttp.ClientError) as err:
|
except (asyncio.TimeoutError, aiohttp.ClientError) as err:
|
||||||
_LOGGER.error("Could not get data from ComEd API: %s", err)
|
_LOGGER.error("Could not get data from ComEd API: %s", err)
|
||||||
|
|
|
@ -11,8 +11,7 @@ from homeassistant.components.comfoconnect import (
|
||||||
ATTR_CURRENT_HUMIDITY, ATTR_OUTSIDE_TEMPERATURE,
|
ATTR_CURRENT_HUMIDITY, ATTR_OUTSIDE_TEMPERATURE,
|
||||||
ATTR_OUTSIDE_HUMIDITY, ATTR_AIR_FLOW_SUPPLY,
|
ATTR_OUTSIDE_HUMIDITY, ATTR_AIR_FLOW_SUPPLY,
|
||||||
ATTR_AIR_FLOW_EXHAUST, SIGNAL_COMFOCONNECT_UPDATE_RECEIVED)
|
ATTR_AIR_FLOW_EXHAUST, SIGNAL_COMFOCONNECT_UPDATE_RECEIVED)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import CONF_RESOURCES, TEMP_CELSIUS
|
||||||
CONF_RESOURCES, TEMP_CELSIUS, STATE_UNKNOWN)
|
|
||||||
from homeassistant.helpers.dispatcher import dispatcher_connect
|
from homeassistant.helpers.dispatcher import dispatcher_connect
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
|
|
||||||
|
@ -122,7 +121,7 @@ class ComfoConnectSensor(Entity):
|
||||||
try:
|
try:
|
||||||
return self._ccb.data[self._sensor_id]
|
return self._ccb.data[self._sensor_id]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return STATE_UNKNOWN
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
|
|
|
@ -9,7 +9,6 @@ from datetime import timedelta
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.const import STATE_UNKNOWN
|
|
||||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
|
@ -73,7 +72,7 @@ class WanIpSensor(Entity):
|
||||||
self.resolver = aiodns.DNSResolver(loop=self.hass.loop)
|
self.resolver = aiodns.DNSResolver(loop=self.hass.loop)
|
||||||
self.resolver.nameservers = [resolver]
|
self.resolver.nameservers = [resolver]
|
||||||
self.querytype = 'AAAA' if ipv6 else 'A'
|
self.querytype = 'AAAA' if ipv6 else 'A'
|
||||||
self._state = STATE_UNKNOWN
|
self._state = None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
|
@ -97,4 +96,4 @@ class WanIpSensor(Entity):
|
||||||
if response:
|
if response:
|
||||||
self._state = response[0].host
|
self._state = response[0].host
|
||||||
else:
|
else:
|
||||||
self._state = STATE_UNKNOWN
|
self._state = None
|
||||||
|
|
|
@ -13,7 +13,7 @@ import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_HOST, CONF_PORT, EVENT_HOMEASSISTANT_STOP, STATE_UNKNOWN)
|
CONF_HOST, CONF_PORT, EVENT_HOMEASSISTANT_STOP)
|
||||||
from homeassistant.core import CoreState
|
from homeassistant.core import CoreState
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
|
@ -270,7 +270,7 @@ class DSMREntity(Entity):
|
||||||
if value is not None:
|
if value is not None:
|
||||||
return value
|
return value
|
||||||
|
|
||||||
return STATE_UNKNOWN
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unit_of_measurement(self):
|
def unit_of_measurement(self):
|
||||||
|
@ -287,7 +287,7 @@ class DSMREntity(Entity):
|
||||||
if value == '0001':
|
if value == '0001':
|
||||||
return 'low'
|
return 'low'
|
||||||
|
|
||||||
return STATE_UNKNOWN
|
return None
|
||||||
|
|
||||||
|
|
||||||
class DerivativeDSMREntity(DSMREntity):
|
class DerivativeDSMREntity(DSMREntity):
|
||||||
|
@ -300,7 +300,7 @@ class DerivativeDSMREntity(DSMREntity):
|
||||||
|
|
||||||
_previous_reading = None
|
_previous_reading = None
|
||||||
_previous_timestamp = None
|
_previous_timestamp = None
|
||||||
_state = STATE_UNKNOWN
|
_state = None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self):
|
||||||
|
|
|
@ -13,7 +13,7 @@ import voluptuous as vol
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
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_VALUE_TEMPLATE, STATE_UNKNOWN, CONF_UNIT_OF_MEASUREMENT)
|
CONF_NAME, CONF_VALUE_TEMPLATE, CONF_UNIT_OF_MEASUREMENT)
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
|
|
||||||
REQUIREMENTS = ['dweepy==0.3.0']
|
REQUIREMENTS = ['dweepy==0.3.0']
|
||||||
|
@ -69,7 +69,7 @@ class DweetSensor(Entity):
|
||||||
self.dweet = dweet
|
self.dweet = dweet
|
||||||
self._name = name
|
self._name = name
|
||||||
self._value_template = value_template
|
self._value_template = value_template
|
||||||
self._state = STATE_UNKNOWN
|
self._state = None
|
||||||
self._unit_of_measurement = unit_of_measurement
|
self._unit_of_measurement = unit_of_measurement
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -92,11 +92,11 @@ class DweetSensor(Entity):
|
||||||
self.dweet.update()
|
self.dweet.update()
|
||||||
|
|
||||||
if self.dweet.data is None:
|
if self.dweet.data is None:
|
||||||
self._state = STATE_UNKNOWN
|
self._state = None
|
||||||
else:
|
else:
|
||||||
values = json.dumps(self.dweet.data[0]['content'])
|
values = json.dumps(self.dweet.data[0]['content'])
|
||||||
self._state = self._value_template.render_with_possible_json_value(
|
self._state = self._value_template.render_with_possible_json_value(
|
||||||
values, STATE_UNKNOWN)
|
values, None)
|
||||||
|
|
||||||
|
|
||||||
class DweetData:
|
class DweetData:
|
||||||
|
|
|
@ -16,7 +16,7 @@ import voluptuous as vol
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
STATE_UNKNOWN, CONF_UNIT_OF_MEASUREMENT, CONF_NAME,
|
CONF_UNIT_OF_MEASUREMENT, CONF_NAME,
|
||||||
CONF_LATITUDE, CONF_LONGITUDE, CONF_RADIUS, CONF_URL)
|
CONF_LATITUDE, CONF_LONGITUDE, CONF_RADIUS, CONF_URL)
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ class GeoRssServiceSensor(Entity):
|
||||||
"""Initialize the sensor."""
|
"""Initialize the sensor."""
|
||||||
self._category = category
|
self._category = category
|
||||||
self._service_name = service_name
|
self._service_name = service_name
|
||||||
self._state = STATE_UNKNOWN
|
self._state = None
|
||||||
self._state_attributes = None
|
self._state_attributes = None
|
||||||
self._unit_of_measurement = unit_of_measurement
|
self._unit_of_measurement = unit_of_measurement
|
||||||
from georss_client.generic_feed import GenericFeed
|
from georss_client.generic_feed import GenericFeed
|
||||||
|
|
|
@ -97,7 +97,7 @@ class GoogleWifiSensor(Entity):
|
||||||
"""Initialize a Google Wifi sensor."""
|
"""Initialize a Google Wifi sensor."""
|
||||||
self._api = api
|
self._api = api
|
||||||
self._name = name
|
self._name = name
|
||||||
self._state = STATE_UNKNOWN
|
self._state = None
|
||||||
|
|
||||||
variable_info = MONITORED_CONDITIONS[variable]
|
variable_info = MONITORED_CONDITIONS[variable]
|
||||||
self._var_name = variable
|
self._var_name = variable
|
||||||
|
@ -135,7 +135,7 @@ class GoogleWifiSensor(Entity):
|
||||||
if self.available:
|
if self.available:
|
||||||
self._state = self._api.data[self._var_name]
|
self._state = self._api.data[self._var_name]
|
||||||
else:
|
else:
|
||||||
self._state = STATE_UNKNOWN
|
self._state = None
|
||||||
|
|
||||||
|
|
||||||
class GoogleWifiAPI:
|
class GoogleWifiAPI:
|
||||||
|
|
|
@ -10,7 +10,7 @@ import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_LATITUDE, ATTR_LONGITUDE, STATE_UNKNOWN, CONF_HOST, CONF_PORT,
|
ATTR_LATITUDE, ATTR_LONGITUDE, CONF_HOST, CONF_PORT,
|
||||||
CONF_NAME)
|
CONF_NAME)
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
@ -93,7 +93,7 @@ class GpsdSensor(Entity):
|
||||||
return "3D Fix"
|
return "3D Fix"
|
||||||
if self.agps_thread.data_stream.mode == 2:
|
if self.agps_thread.data_stream.mode == 2:
|
||||||
return "2D Fix"
|
return "2D Fix"
|
||||||
return STATE_UNKNOWN
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_state_attributes(self):
|
def device_state_attributes(self):
|
||||||
|
|
|
@ -9,8 +9,7 @@ import logging
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.const import (CONF_HOST, CONF_PORT, CONF_DEVICE,
|
from homeassistant.const import (CONF_HOST, CONF_PORT, CONF_DEVICE,
|
||||||
CONF_NAME, EVENT_HOMEASSISTANT_STOP,
|
CONF_NAME, EVENT_HOMEASSISTANT_STOP)
|
||||||
STATE_UNKNOWN)
|
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
@ -105,7 +104,7 @@ class KWBSensor(Entity):
|
||||||
"""Return the state of value."""
|
"""Return the state of value."""
|
||||||
if self._sensor.value is not None and self._sensor.available:
|
if self._sensor.value is not None and self._sensor.available:
|
||||||
return self._sensor.value
|
return self._sensor.value
|
||||||
return STATE_UNKNOWN
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unit_of_measurement(self):
|
def unit_of_measurement(self):
|
||||||
|
|
|
@ -11,7 +11,6 @@ import requests
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||||
from homeassistant.const import STATE_UNKNOWN
|
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
from homeassistant.util import Throttle
|
from homeassistant.util import Throttle
|
||||||
|
@ -143,7 +142,7 @@ class AirSensor(Entity):
|
||||||
if sites_status:
|
if sites_status:
|
||||||
self._state = max(set(sites_status), key=sites_status.count)
|
self._state = max(set(sites_status), key=sites_status.count)
|
||||||
else:
|
else:
|
||||||
self._state = STATE_UNKNOWN
|
self._state = None
|
||||||
|
|
||||||
|
|
||||||
def parse_species(species_data):
|
def parse_species(species_data):
|
||||||
|
|
|
@ -70,20 +70,20 @@ async def async_setup_platform(hass, config, async_add_entities,
|
||||||
|
|
||||||
def calc_min(sensor_values):
|
def calc_min(sensor_values):
|
||||||
"""Calculate min value, honoring unknown states."""
|
"""Calculate min value, honoring unknown states."""
|
||||||
val = STATE_UNKNOWN
|
val = None
|
||||||
for sval in sensor_values:
|
for sval in sensor_values:
|
||||||
if sval != STATE_UNKNOWN:
|
if sval != STATE_UNKNOWN:
|
||||||
if val == STATE_UNKNOWN or val > sval:
|
if val is None or val > sval:
|
||||||
val = sval
|
val = sval
|
||||||
return val
|
return val
|
||||||
|
|
||||||
|
|
||||||
def calc_max(sensor_values):
|
def calc_max(sensor_values):
|
||||||
"""Calculate max value, honoring unknown states."""
|
"""Calculate max value, honoring unknown states."""
|
||||||
val = STATE_UNKNOWN
|
val = None
|
||||||
for sval in sensor_values:
|
for sval in sensor_values:
|
||||||
if sval != STATE_UNKNOWN:
|
if sval != STATE_UNKNOWN:
|
||||||
if val == STATE_UNKNOWN or val < sval:
|
if val is None or val < sval:
|
||||||
val = sval
|
val = sval
|
||||||
return val
|
return val
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ def calc_mean(sensor_values, round_digits):
|
||||||
val += sval
|
val += sval
|
||||||
count += 1
|
count += 1
|
||||||
if count == 0:
|
if count == 0:
|
||||||
return STATE_UNKNOWN
|
return None
|
||||||
return round(val/count, round_digits)
|
return round(val/count, round_digits)
|
||||||
|
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ class MinMaxSensor(Entity):
|
||||||
if self._sensor_type == v)).capitalize()
|
if self._sensor_type == v)).capitalize()
|
||||||
self._unit_of_measurement = None
|
self._unit_of_measurement = None
|
||||||
self._unit_of_measurement_mismatch = False
|
self._unit_of_measurement_mismatch = False
|
||||||
self.min_value = self.max_value = self.mean = self.last = STATE_UNKNOWN
|
self.min_value = self.max_value = self.mean = self.last = None
|
||||||
self.count_sensors = len(self._entity_ids)
|
self.count_sensors = len(self._entity_ids)
|
||||||
self.states = {}
|
self.states = {}
|
||||||
|
|
||||||
|
@ -164,7 +164,7 @@ class MinMaxSensor(Entity):
|
||||||
def state(self):
|
def state(self):
|
||||||
"""Return the state of the sensor."""
|
"""Return the state of the sensor."""
|
||||||
if self._unit_of_measurement_mismatch:
|
if self._unit_of_measurement_mismatch:
|
||||||
return STATE_UNKNOWN
|
return None
|
||||||
return getattr(self, next(
|
return getattr(self, next(
|
||||||
k for k, v in SENSOR_TYPES.items() if self._sensor_type == v))
|
k for k, v in SENSOR_TYPES.items() if self._sensor_type == v))
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,7 @@ import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.entity import Entity
|
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, ATTR_ATTRIBUTION, STATE_UNKNOWN
|
CONF_NAME, ATTR_ATTRIBUTION)
|
||||||
)
|
|
||||||
|
|
||||||
REQUIREMENTS = ['PyMVGLive==1.1.4']
|
REQUIREMENTS = ['PyMVGLive==1.1.4']
|
||||||
|
|
||||||
|
@ -87,7 +86,7 @@ class MVGLiveSensor(Entity):
|
||||||
self._name = name
|
self._name = name
|
||||||
self.data = MVGLiveData(station, destinations, directions,
|
self.data = MVGLiveData(station, destinations, directions,
|
||||||
lines, products, timeoffset, number)
|
lines, products, timeoffset, number)
|
||||||
self._state = STATE_UNKNOWN
|
self._state = None
|
||||||
self._icon = ICONS['-']
|
self._icon = ICONS['-']
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
@ -13,7 +13,7 @@ import voluptuous as vol
|
||||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
TEMP_CELSIUS, DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_TEMPERATURE,
|
TEMP_CELSIUS, DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_TEMPERATURE,
|
||||||
DEVICE_CLASS_BATTERY, STATE_UNKNOWN)
|
DEVICE_CLASS_BATTERY)
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
|
@ -161,7 +161,7 @@ class NetAtmoSensor(Entity):
|
||||||
|
|
||||||
if data is None:
|
if data is None:
|
||||||
_LOGGER.warning("No data found for %s", self.module_name)
|
_LOGGER.warning("No data found for %s", self.module_name)
|
||||||
self._state = STATE_UNKNOWN
|
self._state = None
|
||||||
return
|
return
|
||||||
|
|
||||||
if self.type == 'temperature':
|
if self.type == 'temperature':
|
||||||
|
|
|
@ -9,7 +9,7 @@ import logging
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_NAME, STATE_UNKNOWN, CONF_UNIT_OF_MEASUREMENT, CONF_PAYLOAD)
|
CONF_NAME, CONF_UNIT_OF_MEASUREMENT, CONF_PAYLOAD)
|
||||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
from homeassistant.components import pilight
|
from homeassistant.components import pilight
|
||||||
|
@ -46,7 +46,7 @@ class PilightSensor(Entity):
|
||||||
|
|
||||||
def __init__(self, hass, name, variable, payload, unit_of_measurement):
|
def __init__(self, hass, name, variable, payload, unit_of_measurement):
|
||||||
"""Initialize the sensor."""
|
"""Initialize the sensor."""
|
||||||
self._state = STATE_UNKNOWN
|
self._state = None
|
||||||
self._hass = hass
|
self._hass = hass
|
||||||
self._name = name
|
self._name = name
|
||||||
self._variable = variable
|
self._variable = variable
|
||||||
|
|
|
@ -18,7 +18,7 @@ from homeassistant.const import (
|
||||||
CONF_METHOD, CONF_PASSWORD, CONF_PAYLOAD, CONF_RESOURCE,
|
CONF_METHOD, CONF_PASSWORD, CONF_PAYLOAD, CONF_RESOURCE,
|
||||||
CONF_UNIT_OF_MEASUREMENT, CONF_USERNAME,
|
CONF_UNIT_OF_MEASUREMENT, CONF_USERNAME,
|
||||||
CONF_VALUE_TEMPLATE, CONF_VERIFY_SSL, CONF_DEVICE_CLASS,
|
CONF_VALUE_TEMPLATE, CONF_VERIFY_SSL, CONF_DEVICE_CLASS,
|
||||||
HTTP_BASIC_AUTHENTICATION, HTTP_DIGEST_AUTHENTICATION, STATE_UNKNOWN)
|
HTTP_BASIC_AUTHENTICATION, HTTP_DIGEST_AUTHENTICATION)
|
||||||
from homeassistant.exceptions import PlatformNotReady
|
from homeassistant.exceptions import PlatformNotReady
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
@ -100,7 +100,7 @@ class RestSensor(Entity):
|
||||||
self._hass = hass
|
self._hass = hass
|
||||||
self.rest = rest
|
self.rest = rest
|
||||||
self._name = name
|
self._name = name
|
||||||
self._state = STATE_UNKNOWN
|
self._state = None
|
||||||
self._unit_of_measurement = unit_of_measurement
|
self._unit_of_measurement = unit_of_measurement
|
||||||
self._device_class = device_class
|
self._device_class = device_class
|
||||||
self._value_template = value_template
|
self._value_template = value_template
|
||||||
|
@ -159,11 +159,9 @@ class RestSensor(Entity):
|
||||||
_LOGGER.debug("Erroneous JSON: %s", value)
|
_LOGGER.debug("Erroneous JSON: %s", value)
|
||||||
else:
|
else:
|
||||||
_LOGGER.warning("Empty reply found when expecting JSON data")
|
_LOGGER.warning("Empty reply found when expecting JSON data")
|
||||||
if value is None:
|
if value is not None and self._value_template is not None:
|
||||||
value = STATE_UNKNOWN
|
|
||||||
elif self._value_template is not None:
|
|
||||||
value = self._value_template.render_with_possible_json_value(
|
value = self._value_template.render_with_possible_json_value(
|
||||||
value, STATE_UNKNOWN)
|
value, None)
|
||||||
|
|
||||||
self._state = value
|
self._state = value
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ from homeassistant.components.ring import (
|
||||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_ENTITY_NAMESPACE, CONF_MONITORED_CONDITIONS,
|
CONF_ENTITY_NAMESPACE, CONF_MONITORED_CONDITIONS,
|
||||||
STATE_UNKNOWN, ATTR_ATTRIBUTION)
|
ATTR_ATTRIBUTION)
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
from homeassistant.helpers.icon import icon_for_battery_level
|
from homeassistant.helpers.icon import icon_for_battery_level
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ class RingSensor(Entity):
|
||||||
self._kind = SENSOR_TYPES.get(self._sensor_type)[4]
|
self._kind = SENSOR_TYPES.get(self._sensor_type)[4]
|
||||||
self._name = "{0} {1}".format(
|
self._name = "{0} {1}".format(
|
||||||
self._data.name, SENSOR_TYPES.get(self._sensor_type)[0])
|
self._data.name, SENSOR_TYPES.get(self._sensor_type)[0])
|
||||||
self._state = STATE_UNKNOWN
|
self._state = None
|
||||||
self._tz = str(hass.config.time_zone)
|
self._tz = str(hass.config.time_zone)
|
||||||
self._unique_id = '{}-{}'.format(self._data.id, self._sensor_type)
|
self._unique_id = '{}-{}'.format(self._data.id, self._sensor_type)
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@ class RingSensor(Entity):
|
||||||
@property
|
@property
|
||||||
def icon(self):
|
def icon(self):
|
||||||
"""Icon to use in the frontend, if any."""
|
"""Icon to use in the frontend, if any."""
|
||||||
if self._sensor_type == 'battery' and self._state is not STATE_UNKNOWN:
|
if self._sensor_type == 'battery' and self._state is not None:
|
||||||
return icon_for_battery_level(battery_level=int(self._state),
|
return icon_for_battery_level(battery_level=int(self._state),
|
||||||
charging=False)
|
charging=False)
|
||||||
return self._icon
|
return self._icon
|
||||||
|
|
|
@ -12,7 +12,7 @@ from requests.auth import HTTPBasicAuth, HTTPDigestAuth
|
||||||
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 (
|
||||||
CONF_NAME, CONF_RESOURCE, CONF_UNIT_OF_MEASUREMENT, STATE_UNKNOWN,
|
CONF_NAME, CONF_RESOURCE, CONF_UNIT_OF_MEASUREMENT,
|
||||||
CONF_VALUE_TEMPLATE, CONF_VERIFY_SSL, CONF_USERNAME, CONF_HEADERS,
|
CONF_VALUE_TEMPLATE, CONF_VERIFY_SSL, CONF_USERNAME, CONF_HEADERS,
|
||||||
CONF_PASSWORD, CONF_AUTHENTICATION, HTTP_BASIC_AUTHENTICATION,
|
CONF_PASSWORD, CONF_AUTHENTICATION, HTTP_BASIC_AUTHENTICATION,
|
||||||
HTTP_DIGEST_AUTHENTICATION)
|
HTTP_DIGEST_AUTHENTICATION)
|
||||||
|
@ -87,7 +87,7 @@ class ScrapeSensor(Entity):
|
||||||
"""Initialize a web scrape sensor."""
|
"""Initialize a web scrape sensor."""
|
||||||
self.rest = rest
|
self.rest = rest
|
||||||
self._name = name
|
self._name = name
|
||||||
self._state = STATE_UNKNOWN
|
self._state = None
|
||||||
self._select = select
|
self._select = select
|
||||||
self._attr = attr
|
self._attr = attr
|
||||||
self._value_template = value_template
|
self._value_template = value_template
|
||||||
|
@ -129,6 +129,6 @@ class ScrapeSensor(Entity):
|
||||||
|
|
||||||
if self._value_template is not None:
|
if self._value_template is not None:
|
||||||
self._state = self._value_template.render_with_possible_json_value(
|
self._state = self._value_template.render_with_possible_json_value(
|
||||||
value, STATE_UNKNOWN)
|
value, None)
|
||||||
else:
|
else:
|
||||||
self._state = value
|
self._state = value
|
||||||
|
|
|
@ -13,8 +13,7 @@ import voluptuous as vol
|
||||||
|
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||||
from homeassistant.const import (CONF_DEVICES, CONF_EMAIL, CONF_PASSWORD,
|
from homeassistant.const import CONF_DEVICES, CONF_EMAIL, CONF_PASSWORD
|
||||||
STATE_UNKNOWN)
|
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
|
|
||||||
|
|
||||||
|
@ -78,7 +77,7 @@ class TankUtilitySensor(Entity):
|
||||||
self._password = password
|
self._password = password
|
||||||
self._token = token
|
self._token = token
|
||||||
self._device = device
|
self._device = device
|
||||||
self._state = STATE_UNKNOWN
|
self._state = None
|
||||||
self._name = "Tank Utility " + self.device
|
self._name = "Tank Utility " + self.device
|
||||||
self._unit_of_measurement = SENSOR_UNIT_OF_MEASUREMENT
|
self._unit_of_measurement = SENSOR_UNIT_OF_MEASUREMENT
|
||||||
self._attributes = {}
|
self._attributes = {}
|
||||||
|
|
|
@ -13,7 +13,7 @@ import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_ATTRIBUTION, CONF_API_KEY, CONF_SCAN_INTERVAL,
|
ATTR_ATTRIBUTION, CONF_API_KEY, CONF_SCAN_INTERVAL,
|
||||||
CONF_MONITORED_CONDITIONS, STATE_UNKNOWN)
|
CONF_MONITORED_CONDITIONS)
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
|
|
||||||
REQUIREMENTS = ['TravisPy==0.3.5']
|
REQUIREMENTS = ['TravisPy==0.3.5']
|
||||||
|
@ -107,7 +107,7 @@ class TravisCISensor(Entity):
|
||||||
self._repo_name = repo_name
|
self._repo_name = repo_name
|
||||||
self._user = user
|
self._user = user
|
||||||
self._branch = branch
|
self._branch = branch
|
||||||
self._state = STATE_UNKNOWN
|
self._state = None
|
||||||
self._name = "{0} {1}".format(self._repo_name,
|
self._name = "{0} {1}".format(self._repo_name,
|
||||||
SENSOR_TYPES[self._sensor_type][0])
|
SENSOR_TYPES[self._sensor_type][0])
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ class TravisCISensor(Entity):
|
||||||
attrs = {}
|
attrs = {}
|
||||||
attrs[ATTR_ATTRIBUTION] = CONF_ATTRIBUTION
|
attrs[ATTR_ATTRIBUTION] = CONF_ATTRIBUTION
|
||||||
|
|
||||||
if self._build and self._state is not STATE_UNKNOWN:
|
if self._build and self._state is not None:
|
||||||
if self._user and self._sensor_type == 'state':
|
if self._user and self._sensor_type == 'state':
|
||||||
attrs['Owner Name'] = self._user.name
|
attrs['Owner Name'] = self._user.name
|
||||||
attrs['Owner Email'] = self._user.email
|
attrs['Owner Email'] = self._user.email
|
||||||
|
|
|
@ -57,7 +57,7 @@ class XboxSensor(Entity):
|
||||||
def __init__(self, hass, api, xuid):
|
def __init__(self, hass, api, xuid):
|
||||||
"""Initialize the sensor."""
|
"""Initialize the sensor."""
|
||||||
self._hass = hass
|
self._hass = hass
|
||||||
self._state = STATE_UNKNOWN
|
self._state = None
|
||||||
self._presence = {}
|
self._presence = {}
|
||||||
self._xuid = xuid
|
self._xuid = xuid
|
||||||
self._api = api
|
self._api = api
|
||||||
|
@ -117,5 +117,5 @@ class XboxSensor(Entity):
|
||||||
def update(self):
|
def update(self):
|
||||||
"""Update state data from Xbox API."""
|
"""Update state data from Xbox API."""
|
||||||
presence = self._api.get_user_presence(self._xuid)
|
presence = self._api.get_user_presence(self._xuid)
|
||||||
self._state = presence.get('state', STATE_UNKNOWN)
|
self._state = presence.get('state')
|
||||||
self._presence = presence.get('devices', {})
|
self._presence = presence.get('devices', {})
|
||||||
|
|
|
@ -12,7 +12,7 @@ import voluptuous as vol
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
TEMP_CELSIUS, CONF_MONITORED_CONDITIONS, CONF_NAME, STATE_UNKNOWN,
|
TEMP_CELSIUS, CONF_MONITORED_CONDITIONS, CONF_NAME,
|
||||||
ATTR_ATTRIBUTION)
|
ATTR_ATTRIBUTION)
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
from homeassistant.util import Throttle
|
from homeassistant.util import Throttle
|
||||||
|
@ -99,7 +99,7 @@ class YahooWeatherSensor(Entity):
|
||||||
self._client = name
|
self._client = name
|
||||||
self._name = SENSOR_TYPES[sensor_type][0]
|
self._name = SENSOR_TYPES[sensor_type][0]
|
||||||
self._type = sensor_type
|
self._type = sensor_type
|
||||||
self._state = STATE_UNKNOWN
|
self._state = None
|
||||||
self._unit = SENSOR_TYPES[sensor_type][1]
|
self._unit = SENSOR_TYPES[sensor_type][1]
|
||||||
self._data = weather_data
|
self._data = weather_data
|
||||||
self._forecast = forecast
|
self._forecast = forecast
|
||||||
|
|
|
@ -27,7 +27,7 @@ class TestFanEntity(unittest.TestCase):
|
||||||
|
|
||||||
def test_fanentity(self):
|
def test_fanentity(self):
|
||||||
"""Test fan entity methods."""
|
"""Test fan entity methods."""
|
||||||
assert 'on' == self.fan.state
|
assert 'off' == self.fan.state
|
||||||
assert 0 == len(self.fan.speed_list)
|
assert 0 == len(self.fan.speed_list)
|
||||||
assert 0 == self.fan.supported_features
|
assert 0 == self.fan.supported_features
|
||||||
assert {'speed_list': []} == self.fan.state_attributes
|
assert {'speed_list': []} == self.fan.state_attributes
|
||||||
|
|
|
@ -5,7 +5,7 @@ import unittest
|
||||||
from voluptuous.error import MultipleInvalid
|
from voluptuous.error import MultipleInvalid
|
||||||
|
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
STATE_OFF, STATE_ON, STATE_UNKNOWN, STATE_PLAYING, STATE_PAUSED)
|
STATE_OFF, STATE_ON, STATE_PLAYING, STATE_PAUSED)
|
||||||
import homeassistant.components.switch as switch
|
import homeassistant.components.switch as switch
|
||||||
import homeassistant.components.input_number as input_number
|
import homeassistant.components.input_number as input_number
|
||||||
import homeassistant.components.input_select as input_select
|
import homeassistant.components.input_select as input_select
|
||||||
|
@ -119,7 +119,7 @@ class MockMediaPlayer(media_player.MediaPlayerDevice):
|
||||||
|
|
||||||
def turn_on(self):
|
def turn_on(self):
|
||||||
"""Mock turn_on function."""
|
"""Mock turn_on function."""
|
||||||
self._state = STATE_UNKNOWN
|
self._state = None
|
||||||
|
|
||||||
def turn_off(self):
|
def turn_off(self):
|
||||||
"""Mock turn_off function."""
|
"""Mock turn_off function."""
|
||||||
|
|
|
@ -12,7 +12,6 @@ from unittest.mock import Mock
|
||||||
import asynctest
|
import asynctest
|
||||||
from homeassistant.bootstrap import async_setup_component
|
from homeassistant.bootstrap import async_setup_component
|
||||||
from homeassistant.components.sensor.dsmr import DerivativeDSMREntity
|
from homeassistant.components.sensor.dsmr import DerivativeDSMREntity
|
||||||
from homeassistant.const import STATE_UNKNOWN
|
|
||||||
import pytest
|
import pytest
|
||||||
from tests.common import assert_setup_component
|
from tests.common import assert_setup_component
|
||||||
|
|
||||||
|
@ -99,7 +98,7 @@ def test_derivative():
|
||||||
entity = DerivativeDSMREntity('test', '1.0.0')
|
entity = DerivativeDSMREntity('test', '1.0.0')
|
||||||
yield from entity.async_update()
|
yield from entity.async_update()
|
||||||
|
|
||||||
assert entity.state == STATE_UNKNOWN, 'initial state not unknown'
|
assert entity.state is None, 'initial state not unknown'
|
||||||
|
|
||||||
entity.telegram = {
|
entity.telegram = {
|
||||||
'1.0.0': MBusObject([
|
'1.0.0': MBusObject([
|
||||||
|
@ -109,7 +108,7 @@ def test_derivative():
|
||||||
}
|
}
|
||||||
yield from entity.async_update()
|
yield from entity.async_update()
|
||||||
|
|
||||||
assert entity.state == STATE_UNKNOWN, \
|
assert entity.state is None, \
|
||||||
'state after first update should still be unknown'
|
'state after first update should still be unknown'
|
||||||
|
|
||||||
entity.telegram = {
|
entity.telegram = {
|
||||||
|
|
|
@ -169,7 +169,7 @@ class TestGoogleWifiSensor(unittest.TestCase):
|
||||||
sensor = self.sensor_dict[name]['sensor']
|
sensor = self.sensor_dict[name]['sensor']
|
||||||
self.fake_delay(2)
|
self.fake_delay(2)
|
||||||
sensor.update()
|
sensor.update()
|
||||||
assert STATE_UNKNOWN == sensor.state
|
assert sensor.state is None
|
||||||
|
|
||||||
@requests_mock.Mocker()
|
@requests_mock.Mocker()
|
||||||
def test_update_when_value_changed(self, mock_req):
|
def test_update_when_value_changed(self, mock_req):
|
||||||
|
@ -213,7 +213,7 @@ class TestGoogleWifiSensor(unittest.TestCase):
|
||||||
for name in self.sensor_dict:
|
for name in self.sensor_dict:
|
||||||
sensor = self.sensor_dict[name]['sensor']
|
sensor = self.sensor_dict[name]['sensor']
|
||||||
sensor.update()
|
sensor.update()
|
||||||
assert STATE_UNKNOWN == sensor.state
|
assert sensor.state is None
|
||||||
|
|
||||||
def update_side_effect(self):
|
def update_side_effect(self):
|
||||||
"""Mock representation of update function."""
|
"""Mock representation of update function."""
|
||||||
|
|
|
@ -11,7 +11,6 @@ from homeassistant.exceptions import PlatformNotReady
|
||||||
from homeassistant.setup import setup_component
|
from homeassistant.setup import setup_component
|
||||||
import homeassistant.components.sensor as sensor
|
import homeassistant.components.sensor as sensor
|
||||||
import homeassistant.components.sensor.rest as rest
|
import homeassistant.components.sensor.rest as rest
|
||||||
from homeassistant.const import STATE_UNKNOWN
|
|
||||||
from homeassistant.helpers.config_validation import template
|
from homeassistant.helpers.config_validation import template
|
||||||
|
|
||||||
from tests.common import get_test_home_assistant, assert_setup_component
|
from tests.common import get_test_home_assistant, assert_setup_component
|
||||||
|
@ -175,7 +174,7 @@ class TestRestSensor(unittest.TestCase):
|
||||||
self.rest.update = Mock(
|
self.rest.update = Mock(
|
||||||
'rest.RestData.update', side_effect=self.update_side_effect(None))
|
'rest.RestData.update', side_effect=self.update_side_effect(None))
|
||||||
self.sensor.update()
|
self.sensor.update()
|
||||||
assert STATE_UNKNOWN == self.sensor.state
|
assert self.sensor.state is None
|
||||||
assert not self.sensor.available
|
assert not self.sensor.available
|
||||||
|
|
||||||
def test_update_when_value_changed(self):
|
def test_update_when_value_changed(self):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue