mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 12:47:08 +00:00
Adjust history as all scripts can now be canceled (#37820)
This commit is contained in:
parent
36dde3ff68
commit
f8d547f2d3
@ -73,12 +73,9 @@ IGNORE_DOMAINS = ("zone", "scene")
|
|||||||
NEED_ATTRIBUTE_DOMAINS = {
|
NEED_ATTRIBUTE_DOMAINS = {
|
||||||
"climate",
|
"climate",
|
||||||
"humidifier",
|
"humidifier",
|
||||||
"script",
|
|
||||||
"thermostat",
|
"thermostat",
|
||||||
"water_heater",
|
"water_heater",
|
||||||
}
|
}
|
||||||
SCRIPT_DOMAIN = "script"
|
|
||||||
ATTR_CAN_CANCEL = "can_cancel"
|
|
||||||
|
|
||||||
QUERY_STATES = [
|
QUERY_STATES = [
|
||||||
States.domain,
|
States.domain,
|
||||||
@ -380,17 +377,7 @@ def _sorted_states_to_json(
|
|||||||
domain = split_entity_id(ent_id)[0]
|
domain = split_entity_id(ent_id)[0]
|
||||||
ent_results = result[ent_id]
|
ent_results = result[ent_id]
|
||||||
if not minimal_response or domain in NEED_ATTRIBUTE_DOMAINS:
|
if not minimal_response or domain in NEED_ATTRIBUTE_DOMAINS:
|
||||||
if domain == SCRIPT_DOMAIN:
|
|
||||||
ent_results.extend(
|
|
||||||
[
|
|
||||||
native_state
|
|
||||||
for native_state in (LazyState(db_state) for db_state in group)
|
|
||||||
if native_state.attributes.get(ATTR_CAN_CANCEL)
|
|
||||||
]
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
ent_results.extend(LazyState(db_state) for db_state in group)
|
ent_results.extend(LazyState(db_state) for db_state in group)
|
||||||
continue
|
|
||||||
|
|
||||||
# With minimal response we only provide a native
|
# With minimal response we only provide a native
|
||||||
# State for the first and last response. All the states
|
# State for the first and last response. All the states
|
||||||
|
@ -690,7 +690,6 @@ class TestComponentHistory(unittest.TestCase):
|
|||||||
therm = "thermostat.test"
|
therm = "thermostat.test"
|
||||||
therm2 = "thermostat.test2"
|
therm2 = "thermostat.test2"
|
||||||
zone = "zone.home"
|
zone = "zone.home"
|
||||||
script_nc = "script.cannot_cancel_this_one"
|
|
||||||
script_c = "script.can_cancel_this_one"
|
script_c = "script.can_cancel_this_one"
|
||||||
|
|
||||||
def set_state(entity_id, state, **kwargs):
|
def set_state(entity_id, state, **kwargs):
|
||||||
@ -732,7 +731,6 @@ class TestComponentHistory(unittest.TestCase):
|
|||||||
set_state(mp, "YouTube", attributes={"media_title": str(sentinel.mt3)})
|
set_state(mp, "YouTube", attributes={"media_title": str(sentinel.mt3)})
|
||||||
# This state will be skipped because domain is excluded
|
# This state will be skipped because domain is excluded
|
||||||
set_state(zone, "zoning")
|
set_state(zone, "zoning")
|
||||||
set_state(script_nc, "off")
|
|
||||||
states[script_c].append(
|
states[script_c].append(
|
||||||
set_state(script_c, "off", attributes={"can_cancel": True})
|
set_state(script_c, "off", attributes={"can_cancel": True})
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user