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

Home Assistant sidebar #1880

Closed
wants to merge 11 commits into from
Closed

Conversation

kubawolanin
Copy link
Contributor

@kubawolanin kubawolanin commented Jan 23, 2022

A long time ago in a galaxy far far away I've made an Items explorer for openhab-vscode extension.

This PR implements a sidebar with the following Tree Views:

  • Entities - to quickly copy their IDs, visit log book and history chart for them. Copying their ID handles multiselection as well, so this could potentially be a gateway to dynamically create snippets for groups etc. This view is also filterable - simply start typing after clicking on any row. Read more here
  • Reload - to reload parts of Home Assistant right from the sidebar. These commands were already implemented and I've simply found them a place on the UI.
  • Help And Feedback - a quick access to the docs, community forum as well as GitHub issues to this extension.

Demo

Entities:
2022-01-23-09-50-06

Create a group:
2022-01-25-11-47-19

TODO:

I know it's a lot to grasp, but it'll be quite a useful feature once it's done 🙌🏻

Cheers! 🍻

package.json Outdated Show resolved Hide resolved
@@ -25,6 +25,7 @@
"license": "MIT",
"icon": "assets/logo.png",
"activationEvents": [
"onCommand:vscode-home-assistant.fetchEntities",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add other commands there?

src/extension.ts Outdated Show resolved Hide resolved
if (entities) {
const values: HassEntity[] = Object.values(entities);
await vscode.window.showInformationMessage(
`Fetched ${values.length} entities`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think it's needed anymore

await client.sendRequest("renderTemplate", { template: selectedText });
`${extensionId}.openEntityLogbook`,
(treeItem) => {
const { hostUrl } = vscode.workspace.getConfiguration()[extensionId];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need a clever way to detect if we're using process.env.HASS_SERVER and process.env.HASS_TOKEN that's outside language server.

src/extension.ts Show resolved Hide resolved
src/sidebar/entities.ts Show resolved Hide resolved
return Promise.resolve(this.getEntityTreeItems(this.entities));
}

void vscode.window.showInformationMessage("No entities found");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a simple output log will suffice

@frenck
Copy link
Collaborator

frenck commented Jan 24, 2022

Stop relying on language server's haConnection / websocket subscription and make a REST call to get /states. This will make things a lot faster, since right now the Entities sidebar waits for LanguageServer to finish loading.

We should not be using the REST endpoint. If anything, we should get rid of all rest. The REST endpoint isn't really kept up to date or maintained. All of HA is built on top of the WebSockets nowadays.

@kubawolanin
Copy link
Contributor Author

We should not be using the REST endpoint. If anything, we should get rid of all rest. The REST endpoint isn't really kept up to date or maintained.

Interesting, haven't seen it mentioned in REST API docs and thought it can be used. Thanks for the heads up.

@kubawolanin kubawolanin marked this pull request as ready for review January 26, 2022 07:13
@frenck
Copy link
Collaborator

frenck commented Jan 27, 2022

Your latest addition for groups, will actually create old-style (original for the old, removed states-UI) groups.

These groups are actually discouraged. As of Home Assistant 2022.2, the groups.yaml isn't even created anymore (on new installs).

The use of platform-specific groups is preferred and function a lot better.

@kubawolanin
Copy link
Contributor Author

These groups are actually discouraged

Could you point me where exactly are they discouraged?
They're still supported though, aren't they? I'm sure someone will find this useful anyways.

The use of platform-specific groups

Do you mean cover.group and light.group?

I could write a logic that iterates over domains of selected entities, and if they're all the same, the result snippet would be platform-specific...

@frenck
Copy link
Collaborator

frenck commented Jan 28, 2022

Could you point me where exactly are they discouraged?

We are removing them in multiple places, e.g., the groups.yaml is no more as of this release.

As said, the generic groups are leftover from the old UI interface. In most cases, specific groups should be used.

For example, if you want to bundle lights, you should use light groups, not groups.

The old groups have quite a few issues and often do not provide the expected behavior.

Considering that, I would not recommend adding the creation of old-fashioned groups like this.

@stale
Copy link

stale bot commented Apr 16, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Apr 16, 2022
@stale stale bot closed this Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants