GithubHelp home page GithubHelp logo

State about tileboard HOT 13 CLOSED

resoai avatar resoai commented on May 19, 2024
State

from tileboard.

Comments (13)

 avatar commented on May 19, 2024

You might be confusing state map with actual state i.e.

states: {on: 'Enabled', off: 'Disabled'}, // object of states map, used for mapping of states
//states: function (item, entity) {return entity.state}, // ot use function for getting state

and

//state: String || Function, // custom state of Tile

from tileboard.

Evgeny- avatar Evgeny- commented on May 19, 2024

@VPNMASTER Please show an example of tile config

from tileboard.

vassilis-panos avatar vassilis-panos commented on May 19, 2024
{ // Media center lamp
    position: [0, 1],
    width: 1,
    type: TYPES.LIGHT,
    id: 'light.media_center',
    title: 'Media center',
    subtitle: 'Lamps',
    states: {
        on: "On",
        off: "Off"
    },
    icons: {
        on: 'mdi-lamp',
        off: 'mdi-lamp'
    },
    state: switchPercents('brightness', 255, true),
    sliders: [brightnessSlider()],
}

from tileboard.

vassilis-panos avatar vassilis-panos commented on May 19, 2024

The state function works only If I remove the states mapping

from tileboard.

Evgeny- avatar Evgeny- commented on May 19, 2024

There was two separate elements that was able to show different states. Now it's only one, and states map have bigger priority. Though you still can handle in the state callback function.

Something like:

state: function (item, entity) {
   if('brightness' in entity.attributes) {
      return switchPercents('brightness', 255, true)(item, entity);
   }

   return ({on: "On", off: "Off"})[entity.state];
},

from tileboard.

vassilis-panos avatar vassilis-panos commented on May 19, 2024

Yes, finally I end up with doing this way.
But previous behavior where fall back to mapping when state (ex sub) is null was better.

from tileboard.

Evgeny- avatar Evgeny- commented on May 19, 2024

It's only look that way, in fact there was two elements and the second one overlap the first. So second one showed only when brightness was available, and the first one (on/off) was always in place.

from tileboard.

 avatar commented on May 19, 2024

I think that sub was a bit confusing since you have been describing same element in two different places with two different names. You can easily create a helper function which would show % and on/off for all of your lights.

from tileboard.

Evgeny- avatar Evgeny- commented on May 19, 2024

So there's no problem to fallback into .state when states[entity.state] is null, but in fact it's never null in this case.

from tileboard.

vassilis-panos avatar vassilis-panos commented on May 19, 2024

Sorry, I meant the return of anonymous function and not the entity.state

from tileboard.

Evgeny- avatar Evgeny- commented on May 19, 2024

Oh yes, i got it. I'm looking into changing priorities from states->state to state->states., probably that should solve the problem, in this case.

from tileboard.

Evgeny- avatar Evgeny- commented on May 19, 2024

@VPNMASTER I've pushed new version, please try it out

from tileboard.

vassilis-panos avatar vassilis-panos commented on May 19, 2024

Thank you guys. Works like a charm

from tileboard.

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.