Changing the States displayed on the frontend of a entity based on another sensor state

Hi!

I have a common wall switch for light controlled by Switchbot (robot that can press buttons)


I control the robot via HA, but HA can’t know the real state of light. This is the robot control on HA Schermata 22-10-2020 14.22.57 Schermata 22-10-2020 14.22.40

I have also a Hue Light motion sensor, I would like to set the state of light based on how many lux the hue sensor detects

Schermata 22-10-2020 14.23.33

So if lux are >30 change ‘‘Alogene’’/switch.switchbot to on, but I want only to change the state and not to physically trigger the switch.

Ej. less tha 10 lux --> light switch is off. More than 50lux–> Light switch is on

You could use a template switch and in the value template put the lux check you want.

I tried to use it, but I don’t know how to set it properly. How to set over x lux consider it on, under x lux consider it off.

switch:
  - platform: template
    switches:
      alogene:
        value_template: "{{ is_state('sensor.hue_motion_sensor_1_light_level', 'on') }}"
        turn_on:
          service: switch.turn_on
          data:
            entity_id: switch.switchbot
        turn_off:
          service: switch.turn_off
          data:
            entity_id: switch.switchbot

Try this:

You almost got it, try this:

switch:
  - platform: template
    switches:
      alogene:
        value_template: "{{ states('sensor.hue_motion_sensor_1_light_level') | float > 30 }}"
        turn_on:
          service: switch.turn_on
          data:
            entity_id: switch.switchbot
        turn_off:
          service: switch.turn_off
          data:
            entity_id: switch.switchbot

This should show “on” when the lux is above 30.