function tempToColor(temp, min = 50, max = 90) {
// map temperature to percentage between min and max
var a = (temp - min) / (max - min);
if (a < 0) { a = 0; }
if (a > 1) { a = 1; }
// Linear interpolation between the cold and hot
var h0 = 240;
var h1 = 1;
var h = (h0) * (1 - a) + (h1) * (a);
return 'hsl('+ h +', 100%, 31%)';
}
Adjust the min and max values in that function to suit your preferences (especially if you’re in the world of celsius). h0 and h1 can also be modified to different hue values to shift the color gradient
I’ve just pushed an update which would allow you to do things like:
{
position: [1, 0],
type: TYPES.SENSOR,
title: 'Downstairs',
id: 'sensor.downstairs_avg_temperature',
unit: 'C',
state: false,
customStyles: function(item, entity){
var min = 10, max = 26;
var a = (entity.state - min) / (max - min);
if (a < 0) a = 0;
if (a > 1) a = 1;
var h0 = 240, h1 = 1;
var h = (h0) * (1 - a) + (h1) * (a);
return {
'backgroundColor': 'hsl('+ h +', 100%, 31%)'
}
},
},
Hi @resoai just wondering if you were able to shed any light on why i wouldnt be able to open the dashboard on Android tablet? It runs fine on Chromium on my raspberry pi as well as Safari on my Macbook. When i load the page on my Samsung Android tablet using either the default browser or chrome it shows “System Error” in the top left corner and thats it… doesnt say anything else.
Likely some kind of config error. There should be an error (or errors) in the developer console. You can access it by plugging the tablet in to your computer over USB and using Chrome’s Remote Devices tool in the developer console.
Ahh great, thank you @cgarwood i was wondering how i could access the developer console on a tablet. I’ll give it a go when i get home tonight. Cheers.
Hi all,
I’m trying to print out the date and time the Ring Doorbell was last pressed. I have this:
{
position: [0, 3],
height: .5,
width: 2,
type: TYPES.TEXT_LIST,
title: 'Front Door',
id: {}, // using empty object for an unknown id
state: false, // disable state element
list: [{
title: 'Doorbell',
icon: 'mdi-doorbell-video',
value: '&sensor.ring_front_door_last_ding.attributes.created_at'
},
{
title: 'Motion',
icon: 'mdi-run-fast',
value: '&sensor.ring_front_door_last_motion.attributes.created_at'
},
]
},
The date prints out as: " 2018-07-02T09:47:24+10:00". Any idea if/how to use a filter to clean it up to the current date and time, taking into account the +10:00 offset?
Thanks
This method solved it. Turns out for what ever reason android tablets can’t read hassio.local as a web address so changed the wsURL to the IP address and it works great now.
Got it running nicely now in Fully Kiosk browser with motion detection.