How to modify contact sensor color state

Im trying to invert the state color for the contact sensor (open/close) in the dashboard.

There are several ways to do this. Depends on the type of contact sensor, and/or whether you only want just this instance, or all contact sensors, to invert open/closed state.

Options, depending on what hou have and what you want to do:

  1. Some contact sensor device drivers have a preference setting to invert the sense of the sensor. This is the optimal choice.

  2. You could edit the css for the tile, but this might affect all contact sensors.

  3. Myself, I would do a quick & dirty hack if the device driver didn’t have a sense invert preference: create a virtual contact sensor device (there are some that have both switch and contact sensor capabilities), then a simple rule, triggered by the “real” contact sensor changed, that inverts the virtual sensor’s state. Put the virtual sensor on the dashboard.

In dashboard, select options (gear icon). Click on advanced. Under layout, find customcolors modify or add something like this

{
  "template": "contact",
  "bgColor": "rgb(87,0,0)",
  "iconColor": "rgb(255,255,255)",
  "state": "closed",
  "customIcon": ""
},
{
  "template": "contact",
  "bgColor": "rgb(36,255,184)",
  "iconColor": "rgb(0,0,0)",
  "state": "open",
  "customIcon": ""
},
1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.