I’m trying to create a simple oh-cell item on my overview page to toggle a switch for a light on and off. I would like the cell to change colour to yellow when the item has state ON. I’ve used the UI to configure it and the YAML it generates is:
header: Dining room lamp
title: Dining Room Lamp
But the cell doesn’t change colour. What am I doing wrong? I’d appreciate any help please! I’m on 3.1.0.M3
There is a parameter for cells called
on (in the UI configuration page, you need to click on
Show advanced to see it. This parameter needs to evaluate to true for the cell background to have the color given in the
color parameter. So, there are two typical setups:
- You can set on with an expression related to an item state which will result in a white cell when the item is off (or the expression is false) and
color when the item is on (or the expression is true)
- You can just set
on to true and then control the color of the cell with an expression in the
color parameter which will give you the option of having the “off” color be something other than white.
color: '=(item[DiningRoomLamp_Power].state=="ON") ? "green" : "red"'
That works perfectly, thank you!