Set state of light based on the value of a sensor entity

I’m looking already some time for a solution for the following:

My ventilation is set as a light entity. I can change that value from 0-100% and that works fine.

I do have a sensor that “calculates” and gives a value.

For example:

  • normal state = 20%
  • toilet in use = +10%
  • other toilet in use = +10%
  • humidity in bathroom too high = +20%

This all works fine, the value of that sensor is working as expected and no problems so far.

But now I want to send the value that my sensor has to my “light-entity”.

Like: sensor reads as 35 - sends the value as 35% (brightness? ) to my ventilation.

Anyone that can point me in the right direction?

Create an automation with a State Trigger. The Trigger’s entity_id is your sensor.

The automation’s action calls the light.turn_on service. Create a data_template to set brightness_pct to the sensor’s value. The entity_id will be your light.

- alias: Example
    platform: state
    entity_id: sensor.something
    service: light.turn_on
      entity_id: light.something
      brightness_pct: "{{ trigger.to_state.state }}"

Thank you, very easy if you know how to do it, but I was overlooking this.

Works like a charm!

1 Like