Skip to content

Extract the icon and state for logbook state changed events#40039

Merged
bdraco merged 2 commits intohome-assistant:devfrom
bdraco:logbook_extract_icon
Sep 14, 2020
Merged

Extract the icon and state for logbook state changed events#40039
bdraco merged 2 commits intohome-assistant:devfrom
bdraco:logbook_extract_icon

Conversation

@bdraco
Copy link
Member

@bdraco bdraco commented Sep 13, 2020

Proposed change

Extract the icon and state for logbook state changed events.

Supports home-assistant/frontend#6976 (comment)

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 mentioned this pull request Sep 13, 2020
6 tasks
@MartinHjelmare MartinHjelmare changed the title Extract the icon for logbook state changed events. Extract the icon for logbook state changed events Sep 13, 2020
@bdraco bdraco changed the title Extract the icon for logbook state changed events Extract the icon and state for logbook state changed events Sep 13, 2020
@zsarnett
Copy link
Contributor

These changes are now based on the Frontend PR: home-assistant/frontend#6978

@bdraco
Copy link
Member Author

bdraco commented Sep 13, 2020

These changes are now based on the Frontend PR: home-assistant/frontend#6978

I'll make a new PR on top of this one to remove the message for state_changed and domain since the frontend will now handle this (🥳 .. one step closer to localized) once this one merges as that will be a breaking change.

@zsarnett
Copy link
Contributor

zsarnett commented Sep 13, 2020

Im not seeing the icon come back in the frontend. I do see state now which is nice but looking at multiple entries in the log book and no icon.

API Url being called: logbook/2020-09-13T21:00:00.000Z?end_time=2020-09-14T00:00:00.000Z

(I did pull down your changes to my frontend dev environment)

Edit: Here is a pastebin of the results returned https://pastebin.com/1n1fCHXe

@bdraco
Copy link
Member Author

bdraco commented Sep 13, 2020

@zsarnett The icon only comes down if the entity overrides the icon. This should be the rare case

@zsarnett
Copy link
Contributor

So the main reasoning for pulling the icon in the frontend would be to represent the icons from the state they were changed to with that entry into the log book.

Example if the Kitchen Window was closed. I would expect to see the closed window icon and if it was open I would expect to see the open Window icon on that entry.

In the frontend we usually get the icon via that attributes of that entity. But that is only the currently icon. From this log book query in the backend I was hoping that the icon could be sent to use to know what icon it was at that time of the entry.

Maybe this is something we should do on the frontend with the state and domain. But I am not sure if that covers customization and if it doesn't is that what you are saying your icon property does currently.

@bramkragten may know if this is something we can do on the frontend.

@bdraco
Copy link
Member Author

bdraco commented Sep 14, 2020

I think we need a stateIcon from
https://github.com/home-assistant/frontend/blob/dev/src/common/entity/state_icon.ts#L18 stateIcon

that takes

state and icon instead of HassEntity

@bdraco bdraco merged commit 15281f4 into home-assistant:dev Sep 14, 2020
@bdraco bdraco deleted the logbook_extract_icon branch September 14, 2020 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants