Adjust history as all scripts can now be canceled (#37820)

This commit is contained in:
J. Nick Koston 2020-07-14 10:31:34 -10:00 committed by GitHub
parent 36dde3ff68
commit f8d547f2d3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 16 deletions

View file

@ -73,12 +73,9 @@ IGNORE_DOMAINS = ("zone", "scene")
NEED_ATTRIBUTE_DOMAINS = {
"climate",
"humidifier",
"script",
"thermostat",
"water_heater",
}
SCRIPT_DOMAIN = "script"
ATTR_CAN_CANCEL = "can_cancel"
QUERY_STATES = [
States.domain,
@ -380,17 +377,7 @@ def _sorted_states_to_json(
domain = split_entity_id(ent_id)[0]
ent_results = result[ent_id]
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)
continue
ent_results.extend(LazyState(db_state) for db_state in group)
# With minimal response we only provide a native
# State for the first and last response. All the states

View file

@ -690,7 +690,6 @@ class TestComponentHistory(unittest.TestCase):
therm = "thermostat.test"
therm2 = "thermostat.test2"
zone = "zone.home"
script_nc = "script.cannot_cancel_this_one"
script_c = "script.can_cancel_this_one"
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)})
# This state will be skipped because domain is excluded
set_state(zone, "zoning")
set_state(script_nc, "off")
states[script_c].append(
set_state(script_c, "off", attributes={"can_cancel": True})
)