Giter Site home page Giter Site logo

Comments (10)

shannonhochkins avatar shannonhochkins commented on July 23, 2024 2

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.

shannonhochkins avatar shannonhochkins commented on July 23, 2024 1

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.

yep-dev avatar yep-dev commented on July 23, 2024 1

@shannonhochkins yes, I got some invalid output though, preparing the fix PR

from ha-component-kit.

yep-dev avatar yep-dev commented on July 23, 2024 1

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:
2023-08-24 at 16 58 28@2x

After:
2023-08-24 at 17 00 09@2x

from ha-component-kit.

yep-dev avatar yep-dev commented on July 23, 2024

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.

shannonhochkins avatar shannonhochkins commented on July 23, 2024

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.

shannonhochkins avatar shannonhochkins commented on July 23, 2024

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.

shannonhochkins avatar shannonhochkins commented on July 23, 2024

@yep-dev have you managed to try it out yet?

from ha-component-kit.

shannonhochkins avatar shannonhochkins commented on July 23, 2024

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.

shannonhochkins avatar shannonhochkins commented on July 23, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.