From d57674953054184d73b64dfd3a2aa056510e9a76 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Tue, 9 Jun 2020 20:06:52 +0200 Subject: [PATCH 1/2] Fix mobile_app missing state in sensor registration (#36604) --- .../components/mobile_app/webhook.py | 4 ++- tests/components/mobile_app/test_entity.py | 25 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/mobile_app/webhook.py b/homeassistant/components/mobile_app/webhook.py index b278401d864..610173ca337 100644 --- a/homeassistant/components/mobile_app/webhook.py +++ b/homeassistant/components/mobile_app/webhook.py @@ -352,7 +352,9 @@ async def webhook_enable_encryption(hass, config_entry, data): vol.Required(ATTR_SENSOR_TYPE): vol.In(SENSOR_TYPES), vol.Required(ATTR_SENSOR_UNIQUE_ID): cv.string, vol.Optional(ATTR_SENSOR_UOM): cv.string, - vol.Required(ATTR_SENSOR_STATE): vol.Any(None, bool, str, int, float), + vol.Optional(ATTR_SENSOR_STATE, default=None): vol.Any( + None, bool, str, int, float + ), vol.Optional(ATTR_SENSOR_ICON, default="mdi:cellphone"): cv.icon, } ) diff --git a/tests/components/mobile_app/test_entity.py b/tests/components/mobile_app/test_entity.py index 9f91e659fb0..5dc9717ce36 100644 --- a/tests/components/mobile_app/test_entity.py +++ b/tests/components/mobile_app/test_entity.py @@ -161,6 +161,31 @@ async def test_register_sensor_no_state(hass, create_registrations, webhook_clie assert entity.name == "Test 1 Battery State" assert entity.state == STATE_UNKNOWN + reg_resp = await webhook_client.post( + webhook_url, + json={ + "type": "register_sensor", + "data": { + "name": "Backup Battery State", + "type": "sensor", + "unique_id": "backup_battery_state", + }, + }, + ) + + assert reg_resp.status == 201 + + json = await reg_resp.json() + assert json == {"success": True} + await hass.async_block_till_done() + + entity = hass.states.get("sensor.test_1_backup_battery_state") + assert entity + + assert entity.domain == "sensor" + assert entity.name == "Test 1 Backup Battery State" + assert entity.state == STATE_UNKNOWN + async def test_update_sensor_no_state(hass, create_registrations, webhook_client): """Test that sensors can be updated, when there is no (unknown) state.""" From 13fd80affa85ae0e3750eef5111c142ccf5f7c7b Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Tue, 9 Jun 2020 11:07:32 -0700 Subject: [PATCH 2/2] Bumped version to 0.110.7 --- homeassistant/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/const.py b/homeassistant/const.py index e51ff95e97d..7517217f7d2 100644 --- a/homeassistant/const.py +++ b/homeassistant/const.py @@ -1,7 +1,7 @@ """Constants used by Home Assistant components.""" MAJOR_VERSION = 0 MINOR_VERSION = 110 -PATCH_VERSION = "6" +PATCH_VERSION = "7" __short_version__ = f"{MAJOR_VERSION}.{MINOR_VERSION}" __version__ = f"{__short_version__}.{PATCH_VERSION}" REQUIRED_PYTHON_VER = (3, 7, 0)