Skip to content

Colour fields with paste + full palette, and an off-peak grid colour - #77

Open
cerealkiller57540 wants to merge 1 commit into
pacemaker82:mainfrom
cerealkiller57540:feat/color-pickers-offpeak
Open

cerealkiller57540 wants to merge 1 commit into
pacemaker82:mainfrom
cerealkiller57540:feat/color-pickers-offpeak

Conversation

@cerealkiller57540

@cerealkiller57540 cerealkiller57540 commented Nov 27, 2026 •

Copy link
Copy Markdown

Related to #61 (colour options for the grid). This PR does not close it: #61 asks for a colour based on import/export, this one switches the grid colour on a tariff.

Editor: colour fields

The colour fields were plain text boxes. They now use a small custom selector, ha-selector-cpc_color, defined by the card. Mushroom does the same with mush_color.

  • Text field: type or paste any CSS colour: #ffea07, a theme colour name (teal, primary…), var(--my-color), rgba(...). Existing YAML values are shown as they are and left untouched.
  • Swatch: shows the colour and opens the browser's full colour picker, which writes a hex value.
  • Empty field: removes the key, so the default colour applies again.

I tried HA's built-in ui_color and color_rgb selectors first. ui_color only offers about 25 theme colours. color_rgb has no text field, so you can't paste a hex value, and it stores [r, g, b] arrays.

In the card, theme colour names now resolve to var(--<name>-color) through _resolveColor. That covers line, icon, text, label and source colours. [r, g, b] arrays are also accepted.

Grid: off-peak colour

Three new optional grid keys:

Key Meaning
offpeak_entity Entity that tells when off-peak is active: binary_sensor, input_boolean, schedule, or a tariff sensor
offpeak_state State(s) meaning off-peak: a list or comma-separated, case-insensitive, default on
offpeak_color Grid colour while off-peak is active, same formats as color

While off-peak is active, the grid uses offpeak_color for the icon, value, lines and home gradient. All three keys are in the visual editor under Grid › Off-peak Colour. offpeak_entity is added to the watched entities, so the card updates when the tariff changes.

grid:
  entity: sensor.grid_power
  color: "#488fc2"
  offpeak_entity: sensor.linky_tariff
  offpeak_state: "HEURE CREUSE"
  offpeak_color: teal

Testing

  • Editor (HA 2026.11 frontend): pasted a hex value, picked from the palette, emptied a field (the key is removed), and checked that other values are kept as they were.
  • Card: checked in a live HA that the grid takes offpeak_color when the off-peak entity is in a matching state, including an empty offpeak_state with an on entity.
  • Existing configs: nothing changes unless the new keys are set.

The README documents both features.

🤖 Generated with Claude Code

Editor:
- Colour fields use a small custom selector (ha-selector-cpc_color): a text
  field where any CSS colour can be typed or pasted (#ffea07, a theme colour
  name like teal, var(--x), rgba(...)), next to a swatch that opens the
  browser's full colour picker (saved as hex). Emptying the field removes the
  key so the default colour applies again.
- Theme colour names are resolved to var(--<name>-color) in the card, so they
  work for line, icon, text, label and source colours.

Grid off-peak colour:
- New grid options offpeak_entity, offpeak_state (default "on", list or
  comma-separated, case-insensitive) and offpeak_color. While the entity is in
  an off-peak state, the grid uses offpeak_color for icon, value, lines and
  the home gradient.

README documents both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant