Include the first seen context data in the logbook api (#39194)

* Include the context_entity_id in the logbook api

context_entity_id is the first entity seen during
a time period that includes the context

* update test

* more of them

* include friendly name

* pylint wants a ternary

* Refactor

* performance

* fix homekit context

* Fix self describing events

* Fix external_events
This commit is contained in:
J. Nick Koston 2020-08-24 12:44:40 -05:00 committed by GitHub
parent b1c0d8fb6c
commit 6b7a7939d2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 473 additions and 101 deletions

View file

@ -31,7 +31,7 @@ from homeassistant.const import (
UNIT_PERCENTAGE,
__version__,
)
from homeassistant.core import callback as ha_callback, split_entity_id
from homeassistant.core import Context, callback as ha_callback, split_entity_id
from homeassistant.helpers.event import (
async_track_state_change_event,
track_point_in_utc_time,
@ -490,9 +490,12 @@ class HomeAccessory(Accessory):
ATTR_SERVICE: service,
ATTR_VALUE: value,
}
context = Context()
self.hass.bus.async_fire(EVENT_HOMEKIT_CHANGED, event_data)
await self.hass.services.async_call(domain, service, service_data)
self.hass.bus.async_fire(EVENT_HOMEKIT_CHANGED, event_data, context=context)
await self.hass.services.async_call(
domain, service, service_data, context=context
)
@ha_callback
def async_stop(self):