Comments (13)
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.
@VPNMASTER Please show an example of tile config
from tileboard.
{ // 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.
The state function works only If I remove the states mapping
from tileboard.
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.
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.
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.
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.
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.
Sorry, I meant the return of anonymous function and not the entity.state
from tileboard.
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.
@VPNMASTER I've pushed new version, please try it out
from tileboard.
Thank you guys. Works like a charm
from tileboard.
Related Issues (20)
- [BUG] History tiles not working HOT 2
- Hidden function in HEADER_ITEMS.WEATHER not have state argument
- Features request : New element in the screesaver / header item HOT 1
- Unable to access TileBoard outside sidebar
- Way to be able to select playlist from Spotify on media player tile HOT 1
- Rounding numbers in Text_List HOT 1
- Samsung phones: Progressive Web App lacks service worker HOT 9
- Ping unsuccessful message HOT 2
- No standalone usage possible – URL overrides breaking function HOT 2
- Tile(TYPES.SWITCH) on popup page has no action on click HOT 3
- Global variable holding the current version number HOT 1
- Dynamic max and treshholds in gauge
- Can floorplan support be added? Like Lovelace HOT 1
- Google Calendar HOT 1
- How can put a MDI icon in state or title? HOT 2
- Problem with config addon HOT 2
- Power price widget?
- Add Countdown Timer on Screensaver
- homeassistant updated to 2023.4.2, tileboard(ipad mini2, IOS9 safari)can't working HOT 5
- If it is possable to support more map in DEVICE_TRACKER?
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 tileboard.