Humidity sensor should change RGB light color

My first try to use an automation:

- id: '1613935335031'
  alias: Luftfeuchtigkeit niedrig
  description: ''
  trigger:
  - type: humidity
    platform: device
    device_id: f3881f6438b3685f4eff3d55f899c8b6
    entity_id: sensor.unk_manufacturer_unk_model_b2bd6c22_humidity
    domain: sensor
    below: 50
  condition: 
  - below: 50
    condition: numeric_state
    entity_id: sensor.unk_manufacturer_unk_model_b2bd6c22_humidity

  action:
  - service: light.turn_on
    target:
      entity_id: light.tz3000_dbou1ap4_ts0505a_level_light_color_on_off
    data:
      brightness: 255
      rgb_color: 255, 255, 0


The Action is not triggered. Humidity is 45% at the moment. To my understanding the light should turn on and be on full brightness at rgb 255,255,0
Instead the light turns off as soon as I trigger the automation manually.


- id: '1613935335031'
  alias: Luftfeuchtigkeit niedrig
  description: ''
  trigger:
  - platform: numeric_state
    below: 50
    entity_id: sensor.unk_manufacturer_unk_model_b2bd6c22_humidity
  condition: []
  action:
  - service: light.turn_on
    entity_id: light.tz3000_dbou1ap4_ts0505a_level_light_color_on_off
    data:
      brightness: 255
      rgb_color: 255, 255, 0


1 Like

It still ignores the RGB color. The manual control is no problem.

From the docs of `light.turn’ for parameter rgb_color:

A list containing three integers between 0 and 255 representing the RGB color you want the light to be. Three comma-separated integers that represent the color in RGB, within square brackets. Note that the specified RGB value will not change the light brightness, only the color.

So, it‘s

rgb_color: [255,255,0]

or

rgb_color:
  - 255
  - 255
  - 0
1 Like

The automaton is triggered when humidity drops below 50%. Since it’s already below that threshold it will not trigger.

For testing purposes you could replace the sensor with an input_number helper and play with it.

1 Like

Thanks for your answers. Let’s say I would change the color for every 10% increase or decrease of humidity, do I have to make 10 different automation rules? Or can I combine it?

You could basically use one automation with some templates for the colors.

1 Like

But how can I define the ranges in the automation? In the GUI I can set only a condition.

try this (not sure, if it will work)

rgb_color:
  - "{{ states('sensor.unk_manufacturer_unk_model_b2bd6c22_humidity') | int / 100.0 * 255 }}"
  - 255
  - 0

If templating works for red, then you can copy this to the remaining color channels.

1 Like

thanks this helped. The only thing is that the trigger does not execute it:

To my understanding it should trigger on every change of the temperature (I am now using temp instead of humidity).

But it doesn’t
I have to press execute and watch the color change.

No, it only triggers if the above or below thresholds are crossed.

Ok thanks I see.
The “state” trigger should fire on every value change?

grafik

This will only trigger, if state changes from “0” to “100”. Remove From and To arguments and it will trigger on every state change.

1 Like