8000 Change "away" state to align with device_trackers use of "not_home" by PeteBa · Pull Request #9884 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Change "away" state to align with device_trackers use of "not_home" #9884

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 18, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions homeassistant/components/sensor/mqtt_room.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import homeassistant.components.mqtt as mqtt
from homeassistant.components.sensor import PLATFORM_SCHEMA
from homeassistant.const import (
CONF_NAME, CONF_TIMEOUT)
CONF_NAME, CONF_TIMEOUT, STATE_NOT_HOME)
from homeassistant.components.mqtt import CONF_STATE_TOPIC
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
Expand All @@ -39,8 +39,6 @@
DEFAULT_AWAY_TIMEOUT = 0
DEFAULT_TOPIC = 'room_presence'

STATE_AWAY = 'away'

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_DEVICE_ID): cv.string,
vol.Required(CONF_STATE_TOPIC, default=DEFAULT_TOPIC): cv.string,
Expand Down Expand Up @@ -73,7 +71,7 @@ class MQTTRoomSensor(Entity):

def __init__(self, name, state_topic, device_id, timeout, consider_home):
"""Initialize the sensor."""
self._state = STATE_AWAY
self._state = STATE_NOT_HOME
self._name = name
self._state_topic = '{}{}'.format(state_topic, '/+')
self._device_id = slugify(device_id).upper()
Expand Down Expand Up @@ -148,7 +146,7 @@ def update(self):
if self._updated \
and self._consider_home \
and dt.utcnow() - self._updated > self._consider_home:
self._state = STATE_AWAY
self._state = STATE_NOT_HOME


def _parse_update_data(topic, data):
Expand Down
0