Minor sensor fixes (#22884)

* Minor sensor fixes

* Fix tests
This commit is contained in:
Robbie Trencheny authored and GitHub committed 2019-04-08 01:13:26 -07:00
1 parent 2d287d2abe
commit 137d80452d
4 files changed
+6 -6

No files matched your search

+1 -1
View File
@@ -171,7 +171,7 @@ REGISTER_SENSOR_SCHEMA = vol.Schema({
vol.Required(ATTR_SENSOR_NAME): cv.string,
vol.Required(ATTR_SENSOR_TYPE): vol.In(SENSOR_TYPES),
vol.Required(ATTR_SENSOR_UNIQUE_ID): cv.string,
vol.Required(ATTR_SENSOR_UOM): cv.string,
vol.Optional(ATTR_SENSOR_UOM): cv.string,
vol.Required(ATTR_SENSOR_STATE): vol.Any(bool, str, int, float),
vol.Optional(ATTR_SENSOR_ICON, default='mdi:cellphone'): cv.icon,
})
@@ -55,4 +55,4 @@ class MobileAppSensor(MobileAppEntity):
@property
def unit_of_measurement(self):
"""Return the unit of measurement this sensor expresses itself in."""
return self._config[ATTR_SENSOR_UOM]
return self._config.get(ATTR_SENSOR_UOM)
@@ -228,7 +228,7 @@ async def handle_webhook(hass: HomeAssistantType, webhook_id: str,
data[ATTR_SENSOR_TYPE])
async_dispatcher_send(hass, register_signal, data)
return webhook_response({"status": "registered"},
return webhook_response({'success': True},
registration=registration, status=HTTP_CREATED,
headers=headers)
@@ -271,7 +271,7 @@ async def handle_webhook(hass: HomeAssistantType, webhook_id: str,
async_dispatcher_send(hass, SIGNAL_SENSOR_UPDATE, new_state)
resp[unique_id] = {"status": "okay"}
resp[unique_id] = {'success': True}
return webhook_response(resp, registration=registration,
headers=headers)