Calculating Vapor Pressure Deficit (or VPD) in kPa

No, you did not have to do that. You just had to adjust the original template to use your device attributes. However there is no way we could have known your originally specified sensors were incorrect. Only you have access to your developer tools / states menu and thus only you could have known that. Here is what it would look like:

sensor:
 - platform: template
   sensors:
    vapor_deficit:
     friendly_name: "vpd em kPa"
     value_template: >-
       {% set T = state_attr('switch.sonoff_1000xxxx', 'temperature')|float %}
       {% set RH = state_attr('switch.sonoff_1000xxxx', 'humidity')|float %}
       {% set SVP = 0.61078 * e ** (17.2694 * T / (T + 238.3)) %}
       {% set VPD = ((100-RH) / 100) * SVP %}
       {{-VPD | round(2) -}}
     unit_of_measurement: 'kPa'

There is an argument for breaking the temperature and humidity attributes out of the switch entity like you did if you want easier access to them for display in Lovelace and as automation triggers, but it was not required for this sensor.

2 Likes