diff --git a/homeassistant/components/mobile_app/const.py b/homeassistant/components/mobile_app/const.py index 31364ba063da..05d240da909d 100644 --- a/homeassistant/components/mobile_app/const.py +++ b/homeassistant/components/mobile_app/const.py @@ -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, }) diff --git a/homeassistant/components/mobile_app/sensor.py b/homeassistant/components/mobile_app/sensor.py index c6a53ce57ec7..b2846a6002b1 100644 --- a/homeassistant/components/mobile_app/sensor.py +++ b/homeassistant/components/mobile_app/sensor.py @@ -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) diff --git a/homeassistant/components/mobile_app/webhook.py b/homeassistant/components/mobile_app/webhook.py index 7a83ba4e978f..28ef6bccd6ad 100644 --- a/homeassistant/components/mobile_app/webhook.py +++ b/homeassistant/components/mobile_app/webhook.py @@ -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) diff --git a/tests/components/mobile_app/test_entity.py b/tests/components/mobile_app/test_entity.py index 5dc285cfe9ed..3d8e575f6867 100644 --- a/tests/components/mobile_app/test_entity.py +++ b/tests/components/mobile_app/test_entity.py @@ -35,7 +35,7 @@ async def test_sensor(hass, create_registrations, webhook_client): # noqa: F401 assert reg_resp.status == 201 json = await reg_resp.json() - assert json == {'status': 'registered'} + assert json == {'success': True} entity = hass.states.get('sensor.battery_state') assert entity is not None @@ -122,7 +122,7 @@ async def test_sensor_id_no_dupes(hass, create_registrations, # noqa: F401, F81 assert reg_resp.status == 201 reg_json = await reg_resp.json() - assert reg_json == {'status': 'registered'} + assert reg_json == {'success': True} dupe_resp = await webhook_client.post(webhook_url, json=payload)