Skip to content

Cannot return NULL from template for color_temp or hs_color in template light #33469

@alistairg

Description

@alistairg

The problem

HomeAssistant uses the state of hs_color and/or color_temp to correctly render full color lights, and determine which mode they're in. The 'template light' does not support returning a null value for either template, with unhandled exceptions for hs_color as it attempts to parse the return string.

Environment

  • Home Assistant Core release with the issue: 0.107.7
  • Last working Home Assistant Core release (if known): None
  • Operating environment (Home Assistant/Supervised/Docker/venv): HASS
  • Integration causing this issue: template light
  • Link to integration documentation on our website:

Problem-relevant configuration.yaml

- platform: template
    lights:
      ui_alistair_s_office_overhead:
        friendly_name: Alistair's Office Overhead
        value_template: "{{ states.light.alistair_s_office_overhead.state }}"
        level_template: "{{ states.light.alistair_s_office_overhead.attributes.brightness|int if states.light.alistair_s_office_overhead.attributes.brightness else none }}"
        temperature_template: "{{ states.light.alistair_s_office_overhead.attributes.color_temp|int if states.light.alistair_s_office_overhead.attributes.color_temp else none }}"
        color_template: "{{ states.light.alistair_s_office_overhead.attributes.hs_color or none }}"

Additional information

Template should evaluate for 'None' (string constant returned by jinja's none) and pass 'None' upstream to HA.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions