Read carefully, but still ask for help.
This:
component: oh-label-cell
config:
trendItem: DataWBM1W2T08_ValueasNumber
action: analyzer
actionAnalyzerItems:
- DataWBM1W2T08_ValueasNumber
item: DataWBM1W2T08_ValueasNumber
title: Температура коридор
stateAsHeader: true
expandable: false
actionAnalyzerCoordSystem: time
icon: oh:temperature
on: true
color: =(items.Temperature_Limit_Lo.state <
items.DataWBM1W2T08_ValueasNumber.state ? "lightgreen":"red")
slots: null
Does not respond to the condition. Cell color is always white. The result of condition in the Developer Sidebar = lightgreen. Thus, the condition works, but the color of the cell does not change. What’s the problem?
Mark_VG
(Mark)
October 29, 2021, 12:19pm
43
From what I recall the cell colour cannot be set if you are using trendine
JustinG
(JustinG)
October 29, 2021, 4:21pm
44
@Mark_VG is correct, but there is a second problem as well. Even if you get rid of the trendline you probably will not see the results you expect from your comparison. State values held in the items
object are always strings (they are parsed that way from the api return strings). So:
items.X.state < items.Y.state
is a string comparison (for example `“20” > “120” because the comparison starts with the first string characters and the character code for 2 is greater than the code for 1). In order to make that a numerical comparison you need to cast the state values to a numerical type:
Number(items.X,state) < Number(items.Y.state)
Mark_VG, JustinG thank you for feedback
I changed the cell code:
component: oh-label-cell
config:
on: true
item: DataWBM1W2T08_ValueasNumber
title: Температура коридор
stateAsHeader: true
expandable: false
icon: oh:temperature
color: =(Number(items.Temperature_Limit_Lo.state) <
Number(items.DataWBM1W2T08_ValueasNumber.state) ? "lightgreen":"red")
slots: null
But the color of the cell has not changed, it is still white More ideas ?
Oliver2
(Oliver)
October 30, 2021, 8:54am
46
two errors: closing bracket is at wrong place and there is no lightgreen color supported:
color: '=(Number(items.Temperature_Limit_Lo.state) <
Number(items.DataWBM1W2T08_ValueasNumber.state)) ? "green" : "red"'
Mark_VG
(Mark)
October 30, 2021, 9:16am
47
I always try without the expression to see if I have the basics correct. Try just force the colour to red or green etc.
Thanks all for support.
In fact the problem was with “llightgreen”. Replace with “green” and all work fine.
with two conditions everything works for me… I use it for the alarm. 1=armed 0=disarmed…but I don’t know how to insert a third condition: 2=home
component: oh-label-cell
config:
on: true
action: group
actionGroupPopupItem: bridge1allarme
color: "=(items.allarme_OptState.state == '1') ? 'red' : 'green'"
expandable: false
icon: siren
item: allarme_OptState
label: "=(items.allarme_OptState.state == '1') ? 'ARMATO' : 'DISARMATO' "
stateAsHeader: true
subtitle: " "
title: " Allarme"
header: Allarme```
JustinG
(JustinG)
January 23, 2024, 2:47pm
50
The docs cover this kind of situation, but it’s in the advanced section of widget creation:
I solved it, thanks. I attach the solution, it may help someone.
=(items.allarme_OptState.state === '2') ? 'HOME' : (items.allarme_OptState.state === '1') ? 'ARMATO' : 'DISARMATO'