Add binary_sensor

This commit is contained in:
ludeeus
2019-03-08 22:24:47 +01:00
parent ce2d663821
commit 6bd7005957
5 changed files with 85 additions and 13 deletions

View File

@ -1,4 +1,4 @@
"""Sensor platform for blueprint"""
"""Sensor platform for blueprint."""
from homeassistant.helpers.entity import Entity
from . import update_data
from .const import DOMAIN as NAME, DOMAIN_DATA, SENSOR_ICON
@ -27,12 +27,11 @@ class BlueprintSensor(Entity):
# Get new data (if any)
updated = self.hass.data[DOMAIN_DATA]
# Check if there is data
# Check the data and update the value.
if updated.get("title") is None:
updated = self._state
# Set/update the state, and make sure it looks good by capitalizing it
self._state = updated.capitalize()
self._state = self._status
else:
self._state = updated.get("title")
# Set/update attributes
self.attr['user_id'] = updated.get('userId')