Comments (10)
Thanks for the feedback!
Entity types is something i will address, however this is something that would have to be polled by the user, i can easily create a script to sync & create types for a ha-instance, I did it initially for all the services/attributes i currently have, could be a simple cli script bundled with @hakit/core:
hakit-core --sync-entities -user X -password - X
Leave that one with me, I'll try to sort, I myself haven't had any dramas with entities changing unless i have to re-add entities manually.
Another idea i had was to use the yaml configuration to list all the entities you want to use with the custom dashboard, and then retrieve them with the useHass hook const { getConfig } = useHass()
; and use the entities from the config, that way you don't have to re-build / re-deploy anything you just have to update the yaml config from HA.
I realise it's not enough but i'm getting there! It's been a lot of work already to achieve what i have!
I'll see if i can come up with a nice solution here, I also need to provide error boundaries where the hooks try to use something that doesn't exist anymore
from ha-component-kit.
I might ask that you explain your issue a little more @yep-dev if that's okay, I think I've figured out a way to basically "replace" the domains/services/entities that the package uses by default, however is that what you're after?
IE,
import { ServiceFunction, ServiceFunctionTypes, CUSTOM_SERVICES_KEY } from "@hakit/core";
declare module "@hakit/core" {
export interface CustomServicesContainer<T extends ServiceFunctionTypes = "target"> {
[CUSTOM_SERVICES_KEY]: { // <-- Use the unique symbol as a key
light: {
// Turn on one or more lights and adjust properties of the light, even when they are turned on already.
turnOn: ServiceFunction<
T,
{
color_name:'red';
}
>;
};
};
}
}
This would basically only allow something like useEntity
to validate with the light service, ie
const entity = useEntity('light.something');
entity.api.turnOn({
color_name: 'red' // only accepts red now
});
This allows us to completely extend hakit with a predefined module that i can generate with a cli / node script which is married to the users home assistant instance.
Does this make sense? And if i've totally mis-interpreted your original question please let me know, We can do the same with entities to get intellisense but i wanted to drill down into your thoughts with the services first
from ha-component-kit.
@shannonhochkins yes, I got some invalid output though, preparing the fix PR
from ha-component-kit.
Works great; that services part is outstanding, saves a lot of code, and fiddling with HA dev tools, especially for people like me building all components from scratch.
Before:
from ha-component-kit.
Great, the work you've done so far made this flow possible, I appreciate it.
Unfortunately, I don't have enough time to work on this core, but I'll publish my dashboard on GH and later on forums when it's in a decent state to showcase the usage of this package and promote it.
from ha-component-kit.
Thanks a lot mate! I'll see what I can come up with so we have a tighter contract between the home assistant integration and react 🤘
from ha-component-kit.
If you want to give it a crack, I've released this sync tool!
https://shannonhochkins.github.io/ha-component-kit/?path=/docs/introduction-typescriptsync--docs
Obviously you'll need to update @hakit/core and also @hakit/components if you're using it!
from ha-component-kit.
@yep-dev have you managed to try it out yet?
from ha-component-kit.
Awesome man! Glad you're liking it! I have a few more ideas to improve usability like automatic ways to tie in / notify failures of entity names that might change over time so I'll be focusing on that next
from ha-component-kit.
@yep-dev - i was looking through your repository (noticing a few things you're doing to get around bugs) - i noticed you're casting the api type for media_player, i hadn't realised but there was a bug with the api type helper, this has been fixed in the latest version :)
from ha-component-kit.
Related Issues (20)
- Display the settings modal HOT 6
- useEntity not working for light entities that are turned off HOT 6
- Full example code similar to Demo dashboard HOT 2
- useAreas not reporting moved entities correctly HOT 15
- Docs and npm create are bonked HOT 3
- DevContainer HOT 6
- Adding order number for AreaCards in SidebarCard HOT 2
- Area Summary Card HOT 2
- License status HOT 2
- Allow numeric value for media_content_id HOT 2
- Extend entity types generator to include attributes too HOT 6
- Cannot open when added to Home Screen HOT 12
- Card for Calendar entries HOT 7
- Cannot connect to Home Assistant instances over "http://". HOT 9
- I want to use the library with next.js but i got error only in building HOT 9
- Add option to set and update attributes HOT 2
- Can I query a list of area and entities within a area? HOT 8
- Setup CLI issues HOT 10
- Getting a lot of errors when following the contribution documentation HOT 8
- MediaPlayerCard improvements HOT 22
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ha-component-kit.