Read modbus address of a sensor

I want to read the modbus register address of a sensor in a script. Instead of writing the integer value like:

calc_thz_ww_soll_temp:
  sequence:
    - service: modbus.write_register
      data:
        address: 1011

I would like to read it in a expression:

calc_thz_ww_soll_temp:
  sequence:
    - service: modbus.write_register
      data:
        address: {{ state_attr( 'sensor.ww_soll_temp', 'address' )| int }}

The expression returns Null. I do not know, how to use the correct naming. Can anyone help?

1 Like