Template light refresh value_template

Hello,
I have template light and Modbus TCP service. All works fine but I have some issue. When I set light on value is changed immediatelly in modbus register but state of switch is not changed. This is changed in few seconds related to refresh data comming from sensor.
How can I force sensor to refresh data?

sensor:
platform: modbus
registers:
- name: light1
slave: 1
register: 1

light:

  • platform: template
    lights:
    theater_lights:
    friendly_name: “dmx light”
    level_template: “{{ states.sensor.light1.state|int }}”
    value_template: “{{ states.sensor.light1.state|int > 0 }}”
    turn_on:
    service: modbus.write_register
    data_template:
    unit: 1
    address: 1
    value: 66
    turn_off:
    service: modbus.write_register
    data_template:
    unit: 1
    address: 1
    value: 0
    set_level:
    service: modbus.write_register
    data_template:
    unit: 1
    address: 1
    value: “{{ brightness }}”

Please follow the instructions in the blue banner at the top of the page.

sensor:
  platform: modbus
  registers:
- name: light1
  slave: 1
  register: 1

light:
  - platform: template
lights:
  theater_lights:
    friendly_name: "dmx light"
    level_template: "{{ states.sensor.light1.state|int }}"
    value_template: "{{ states.sensor.light1.state|int > 0 }}"
    turn_on:
      service: modbus.write_register
      data_template:
        unit: 1
        address: 1
        value: 66
    turn_off:
      service: modbus.write_register
      data_template:
        unit: 1
        address: 1
        value: 0
    set_level:
      service: modbus.write_register 
      data_template:
        unit: 1
        address: 1
        value:  "{{ brightness }}"

Not sure if this works, but give homeassistant.update_entity a try.

This indentation is incorrect:

light:
  - platform: template
lights:
  theater_lights:
    friendly_name: "dmx light"
    level_template: "{{ states.sensor.light1.state|int }}"
    value_template: "{{ states.sensor.light1.state|int > 0 }}"

It should be:

light:
  - platform: template
      lights:
        theater_lights:
          friendly_name: "dmx light"
          level_template: "{{ states.sensor.light1.state|int }}"
          value_template: "{{ states.sensor.light1.state|int > 0 }}"

works great :wink:
thanks!

right!
formatting seems to be important for yaml