mirror of
https://github.com/home-assistant/core.git
synced 2025-07-28 23:57:06 +00:00
Merge pull request #36492 from home-assistant/0.110.5
This commit is contained in:
commit
cdf4588fb0
@ -57,6 +57,7 @@ ERR_ENCRYPTION_NOT_AVAILABLE = "encryption_not_available"
|
|||||||
ERR_ENCRYPTION_REQUIRED = "encryption_required"
|
ERR_ENCRYPTION_REQUIRED = "encryption_required"
|
||||||
ERR_SENSOR_NOT_REGISTERED = "not_registered"
|
ERR_SENSOR_NOT_REGISTERED = "not_registered"
|
||||||
ERR_SENSOR_DUPLICATE_UNIQUE_ID = "duplicate_unique_id"
|
ERR_SENSOR_DUPLICATE_UNIQUE_ID = "duplicate_unique_id"
|
||||||
|
ERR_INVALID_FORMAT = "invalid_format"
|
||||||
|
|
||||||
|
|
||||||
ATTR_SENSOR_ATTRIBUTES = "attributes"
|
ATTR_SENSOR_ATTRIBUTES = "attributes"
|
||||||
|
@ -76,6 +76,7 @@ from .const import (
|
|||||||
ERR_ENCRYPTION_ALREADY_ENABLED,
|
ERR_ENCRYPTION_ALREADY_ENABLED,
|
||||||
ERR_ENCRYPTION_NOT_AVAILABLE,
|
ERR_ENCRYPTION_NOT_AVAILABLE,
|
||||||
ERR_ENCRYPTION_REQUIRED,
|
ERR_ENCRYPTION_REQUIRED,
|
||||||
|
ERR_INVALID_FORMAT,
|
||||||
ERR_SENSOR_DUPLICATE_UNIQUE_ID,
|
ERR_SENSOR_DUPLICATE_UNIQUE_ID,
|
||||||
ERR_SENSOR_NOT_REGISTERED,
|
ERR_SENSOR_NOT_REGISTERED,
|
||||||
SIGNAL_LOCATION_UPDATE,
|
SIGNAL_LOCATION_UPDATE,
|
||||||
@ -394,20 +395,31 @@ async def webhook_register_sensor(hass, config_entry, data):
|
|||||||
vol.All(
|
vol.All(
|
||||||
cv.ensure_list,
|
cv.ensure_list,
|
||||||
[
|
[
|
||||||
|
# Partial schema, enough to identify schema.
|
||||||
|
# We don't validate everything because otherwise 1 invalid sensor
|
||||||
|
# will invalidate all sensors.
|
||||||
vol.Schema(
|
vol.Schema(
|
||||||
{
|
{
|
||||||
vol.Optional(ATTR_SENSOR_ATTRIBUTES, default={}): dict,
|
|
||||||
vol.Optional(ATTR_SENSOR_ICON, default="mdi:cellphone"): cv.icon,
|
|
||||||
vol.Required(ATTR_SENSOR_STATE): vol.Any(bool, str, int, float),
|
|
||||||
vol.Required(ATTR_SENSOR_TYPE): vol.In(SENSOR_TYPES),
|
vol.Required(ATTR_SENSOR_TYPE): vol.In(SENSOR_TYPES),
|
||||||
vol.Required(ATTR_SENSOR_UNIQUE_ID): cv.string,
|
vol.Required(ATTR_SENSOR_UNIQUE_ID): cv.string,
|
||||||
}
|
},
|
||||||
|
extra=vol.ALLOW_EXTRA,
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
async def webhook_update_sensor_states(hass, config_entry, data):
|
async def webhook_update_sensor_states(hass, config_entry, data):
|
||||||
"""Handle an update sensor states webhook."""
|
"""Handle an update sensor states webhook."""
|
||||||
|
sensor_schema_full = vol.Schema(
|
||||||
|
{
|
||||||
|
vol.Optional(ATTR_SENSOR_ATTRIBUTES, default={}): dict,
|
||||||
|
vol.Optional(ATTR_SENSOR_ICON, default="mdi:cellphone"): cv.icon,
|
||||||
|
vol.Required(ATTR_SENSOR_STATE): vol.Any(bool, str, int, float),
|
||||||
|
vol.Required(ATTR_SENSOR_TYPE): vol.In(SENSOR_TYPES),
|
||||||
|
vol.Required(ATTR_SENSOR_UNIQUE_ID): cv.string,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
resp = {}
|
resp = {}
|
||||||
for sensor in data:
|
for sensor in data:
|
||||||
entity_type = sensor[ATTR_SENSOR_TYPE]
|
entity_type = sensor[ATTR_SENSOR_TYPE]
|
||||||
@ -429,6 +441,19 @@ async def webhook_update_sensor_states(hass, config_entry, data):
|
|||||||
|
|
||||||
entry = hass.data[DOMAIN][entity_type][unique_store_key]
|
entry = hass.data[DOMAIN][entity_type][unique_store_key]
|
||||||
|
|
||||||
|
try:
|
||||||
|
sensor = sensor_schema_full(sensor)
|
||||||
|
except vol.Invalid as err:
|
||||||
|
err_msg = vol.humanize.humanize_error(sensor, err)
|
||||||
|
_LOGGER.error(
|
||||||
|
"Received invalid sensor payload for %s: %s", unique_id, err_msg
|
||||||
|
)
|
||||||
|
resp[unique_id] = {
|
||||||
|
"success": False,
|
||||||
|
"error": {"code": ERR_INVALID_FORMAT, "message": err_msg},
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
|
||||||
new_state = {**entry, **sensor}
|
new_state = {**entry, **sensor}
|
||||||
|
|
||||||
hass.data[DOMAIN][entity_type][unique_store_key] = new_state
|
hass.data[DOMAIN][entity_type][unique_store_key] = new_state
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
"domain": "myq",
|
"domain": "myq",
|
||||||
"name": "MyQ",
|
"name": "MyQ",
|
||||||
"documentation": "https://www.home-assistant.io/integrations/myq",
|
"documentation": "https://www.home-assistant.io/integrations/myq",
|
||||||
"requirements": ["pymyq==2.0.2"],
|
"requirements": ["pymyq==2.0.3"],
|
||||||
"codeowners": ["@bdraco"],
|
"codeowners": ["@bdraco"],
|
||||||
"config_flow": true,
|
"config_flow": true,
|
||||||
"homekit": {
|
"homekit": {
|
||||||
|
@ -120,10 +120,10 @@ def setup(hass, config):
|
|||||||
|
|
||||||
params = {
|
params = {
|
||||||
"version": __version__,
|
"version": __version__,
|
||||||
"external_url": None,
|
"external_url": "",
|
||||||
"internal_url": None,
|
"internal_url": "",
|
||||||
# Old base URL, for backward compatibility
|
# Old base URL, for backward compatibility
|
||||||
"base_url": None,
|
"base_url": "",
|
||||||
# Always needs authentication
|
# Always needs authentication
|
||||||
"requires_api_password": True,
|
"requires_api_password": True,
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
"""Constants used by Home Assistant components."""
|
"""Constants used by Home Assistant components."""
|
||||||
MAJOR_VERSION = 0
|
MAJOR_VERSION = 0
|
||||||
MINOR_VERSION = 110
|
MINOR_VERSION = 110
|
||||||
PATCH_VERSION = "4"
|
PATCH_VERSION = "5"
|
||||||
__short_version__ = f"{MAJOR_VERSION}.{MINOR_VERSION}"
|
__short_version__ = f"{MAJOR_VERSION}.{MINOR_VERSION}"
|
||||||
__version__ = f"{__short_version__}.{PATCH_VERSION}"
|
__version__ = f"{__short_version__}.{PATCH_VERSION}"
|
||||||
REQUIRED_PYTHON_VER = (3, 7, 0)
|
REQUIRED_PYTHON_VER = (3, 7, 0)
|
||||||
|
@ -1468,7 +1468,7 @@ pymsteams==0.1.12
|
|||||||
pymusiccast==0.1.6
|
pymusiccast==0.1.6
|
||||||
|
|
||||||
# homeassistant.components.myq
|
# homeassistant.components.myq
|
||||||
pymyq==2.0.2
|
pymyq==2.0.3
|
||||||
|
|
||||||
# homeassistant.components.mysensors
|
# homeassistant.components.mysensors
|
||||||
pymysensors==0.18.0
|
pymysensors==0.18.0
|
||||||
|
@ -627,7 +627,7 @@ pymodbus==2.3.0
|
|||||||
pymonoprice==0.3
|
pymonoprice==0.3
|
||||||
|
|
||||||
# homeassistant.components.myq
|
# homeassistant.components.myq
|
||||||
pymyq==2.0.2
|
pymyq==2.0.3
|
||||||
|
|
||||||
# homeassistant.components.nut
|
# homeassistant.components.nut
|
||||||
pynut2==2.1.2
|
pynut2==2.1.2
|
||||||
|
@ -57,13 +57,18 @@ async def test_sensor(hass, create_registrations, webhook_client):
|
|||||||
"state": 123,
|
"state": 123,
|
||||||
"type": "sensor",
|
"type": "sensor",
|
||||||
"unique_id": "battery_state",
|
"unique_id": "battery_state",
|
||||||
}
|
},
|
||||||
|
# This invalid data should not invalidate whole request
|
||||||
|
{"type": "sensor", "unique_id": "invalid_state", "invalid": "data"},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert update_resp.status == 200
|
assert update_resp.status == 200
|
||||||
|
|
||||||
|
json = await update_resp.json()
|
||||||
|
assert json["invalid_state"]["success"] is False
|
||||||
|
|
||||||
updated_entity = hass.states.get("sensor.test_1_battery_state")
|
updated_entity = hass.states.get("sensor.test_1_battery_state")
|
||||||
assert updated_entity.state == "123"
|
assert updated_entity.state == "123"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user