Giter Site home page Giter Site logo

Comments (6)

rensknoors avatar rensknoors commented on July 4, 2024 2

What version of @hakit are you using? I just checked my code and i must have run into something similar 2 weeks ago

function toRGB(entity: HassEntity): [number, number, number] | null {
  if (entity.attributes) {
    if ("hs_color" in entity.attributes && entity.attributes.hs_color !== null) {
      return hs2rgb([entity.attributes.hs_color[0], entity.attributes.hs_color[1] / 100]);
    }
    if ("color_temp_kelvin" in entity.attributes && entity.attributes.color_temp_kelvin !== null) {
      return temperature2rgb(entity.attributes.color_temp_kelvin);
    }
    if ("rgb_color" in entity.attributes && entity.attributes.rgb_color !== null) {
      return entity.attributes.rgb_color;
    }
    if ("rgbw_color" in entity.attributes && entity.attributes.rgbw_color !== null) {
      return rgbw2rgb(entity.attributes.rgbw_color);
    }
    if ("rgbww_color" in entity.attributes && entity.attributes.rgbww_color !== null) {
      return rgbww2rgb(entity.attributes.rgbww_color, entity.attributes.min_color_temp_kelvin, entity.attributes.max_color_temp_kelvin);
    }
  }

  return null;
}

This is the toRGB function on the latest version, i suspect you haven't upgraded the packages :)

You're absolutely right, it was fixed after upgrading. I upgraded about 2 weeks ago and then started this issue (but never submitted it because I got distracted) and ran into the same issue again this week. This time I submitted it without checking if there was a new update.

No major issues and even if I encounter one, you apparantly fix them before I can submit a Github issue ;)

from ha-component-kit.

shannonhochkins avatar shannonhochkins commented on July 4, 2024 1

What version of @hakit are you using? I just checked my code and i must have run into something similar 2 weeks ago

function toRGB(entity: HassEntity): [number, number, number] | null {
  if (entity.attributes) {
    if ("hs_color" in entity.attributes && entity.attributes.hs_color !== null) {
      return hs2rgb([entity.attributes.hs_color[0], entity.attributes.hs_color[1] / 100]);
    }
    if ("color_temp_kelvin" in entity.attributes && entity.attributes.color_temp_kelvin !== null) {
      return temperature2rgb(entity.attributes.color_temp_kelvin);
    }
    if ("rgb_color" in entity.attributes && entity.attributes.rgb_color !== null) {
      return entity.attributes.rgb_color;
    }
    if ("rgbw_color" in entity.attributes && entity.attributes.rgbw_color !== null) {
      return rgbw2rgb(entity.attributes.rgbw_color);
    }
    if ("rgbww_color" in entity.attributes && entity.attributes.rgbww_color !== null) {
      return rgbww2rgb(entity.attributes.rgbww_color, entity.attributes.min_color_temp_kelvin, entity.attributes.max_color_temp_kelvin);
    }
  }

  return null;
}

This is the toRGB function on the latest version, i suspect you haven't upgraded the packages :)

from ha-component-kit.

shannonhochkins avatar shannonhochkins commented on July 4, 2024

Thanks for the details! Easy fix, is this error thrown by a custom use case or are you using both packages? Just odd I haven't seen this that's all!

from ha-component-kit.

shannonhochkins avatar shannonhochkins commented on July 4, 2024

Home assistant used to completely remove properties when the device is off, I'll have to take another look into it!

from ha-component-kit.

rensknoors avatar rensknoors commented on July 4, 2024

I made my own custom card for the lights so at first I thought it had something to do with my own code but after some testing I noticed that it was an issue with useEntity.

I have both packages packages installed but I barely use any components from @hakit/components because I create my own custom cards.

It's weird that Home Assistant shows the properties even with null values. I haven't seen this change mentioned in the changelogs while upgrading. Perhaps it's an issue specific to my installation, but useEntity used to work just fine.

from ha-component-kit.

shannonhochkins avatar shannonhochkins commented on July 4, 2024

It's also great to see that you've been designing something from scratch using the core! How's it been going? Had any other major issues? Would appreciate some feedback :)

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.