Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 10 commits into from
Aug 24, 2020

Conversation

bdraco
Copy link
Member

@bdraco bdraco commented Aug 23, 2020

WTH: https://community.home-assistant.io/t/what-the-heck-turned-my-light-on/219488

Frontend change: home-assistant/frontend#6682

Proposed change

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

Limitations:

  • If the entity that triggered the change happened outside the selected logbook time window, it won't be shown.

Service Call:

{
	"context_domain": "switch",
	"context_event_type": "call_service",
	"context_service": "turn_off",
	"context_user_id": "659270f2e98640cd823cbbdb6bf01d19",
	"domain": "switch",
	"entity_id": "switch.bar_dog_water",
	"message": "turned off",
	"name": "Bar Dog Water",
	"when": "2020-08-24T15:10:24.818600+00:00"
}

Automation

{
	"context_entity_id": "automation.turn_on_rack_at_8am_if_house_occupied",
	"context_entity_id_name": "Turn on Rack at 8am if House Occupied",
	"context_event_type": "automation_triggered",
	"domain": "switch",
	"entity_id": "switch.tech_room_rack_night_away_swi",
	"message": "turned on",
	"name": "Tech Room Rack Night Away Swi",
	"when": "2020-08-24T13:00:00.023137+00:00"
}

State change (show which entity triggered the template entity to change)

{
	"context_entity_id": "switch.pool_pump",
	"context_entity_id_name": "Pool",
	"context_event_type": "state_changed",
	"domain": "sensor",
	"entity_id": "sensor.poolspa_mode",
	"message": "changed to pool",
	"name": "Pool Mode",
	"when": "2020-08-24T15:07:20.372892+00:00"
}

HomeKit

{
	"context_entity_id": "light.nick_office_lights",
	"context_entity_id_name": "Nick Office Lights",
	"context_event_type": "homekit_state_change",
	"domain": "light",
	"entity_id": "light.nick_office_lights",
	"message": "turned off",
	"name": "Nick Office Lights",
	"when": "2020-08-24T15:52:23.251478+00:00"
}

Screen Shot 2020-08-23 at 1 15 40 PM

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example entry for configuration.yaml:

# Example configuration.yaml

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

To help with the load of incoming pull requests:

@bdraco bdraco added the WTH Issues & PRs generated from the "Month of What the Heck?" label Aug 23, 2020
context_entity_id is the first entity seen during
a time period that includes the context
@bdraco bdraco changed the title Include the context_entity_id in the logbook api Include the context in the logbook api Aug 24, 2020
@bdraco bdraco changed the title Include the context in the logbook api Include the first seen context data in the logbook api Aug 24, 2020
@bdraco
Copy link
Member Author

bdraco commented Aug 24, 2020

Revalidating performance, then will merge, and rework the frontend PR

@bdraco
Copy link
Member Author

bdraco commented Aug 24, 2020

groups are missing context.

Will fix that in another PR

@bdraco bdraco merged commit 6b7a793 into home-assistant:dev Aug 24, 2020
weissm pushed a commit to weissm/core that referenced this pull request Aug 28, 2020
…t#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
leikoilja pushed a commit to leikoilja/core that referenced this pull request Sep 6, 2020
…t#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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed core has-tests integration: logbook WTH Issues & PRs generated from the "Month of What the Heck?"
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants