Change cell color

Hello,

I want that the color of the cell is changed when the state of my jablotron system is armed or disarmed.
for now i am only able to have the label changed to armed or disarmed.
You can find the yaml code that i use.

You would do something like the following:

component: oh-cell
config:
  color: '=(items.GPSMarkatHome.state === "ON") ? "green" :
    (items.GPSRileyatHome.state === "OFF") ? "green" :
    (items.GPSEthanatHome.state === "OFF") ? "green" : "red"'
  on: true
  title: Presence
slots:
  default:
...

PS. Please use code fences - makes it easier to see what you are doing :slight_smile:

Hello,

I have a similar problem with an item that returns “true” or “false” and I want to change the colour of a cell depending on this. But configuring it in the widget itself with
=(items.VectorF2U7_VectorF2U7_Docked.state == “true”) does not work. It doesn’t seem to work in YAML itself either, what am I doing wrong?

2023-10-18 11_36_24-openHAB

component: oh-cell
config:
  action: analyzer
  actionAnalyzerCoordSystem: time
  actionAnalyzerItems:
    - VectorF2U7_VectorF2U7_Battery
  color: '=(items.VectorF2U7_VectorF2U7_Docked.state === "true") ? "green" : "red"'
  header: Vector Battery
  icon: material:smart_toy
  subtitle: '="Docked: " + (items.VectorF2U7_VectorF2U7_Docked.state)'
  title: =(items.VectorF2U7_VectorF2U7_Battery.displayState)
  trendGradient:
    - "#E64A19"
  trendItem: VectorF2U7_VectorF2U7_Battery

Try remove your trend settings? I seem to recall something about not being able to use both together?

EDIT: You need to add: on: true to the oh-cell config block:

component: oh-cell
config:
  on: true
  action: analyzer
  actionAnalyzerCoordSystem: time
  actionAnalyzerItems:
....
1 Like

ah, ok thank you! If I remove the trend, it works.