Difference between 2 energy sensors

I am a complete newb here, mamange to work out most things so far but stuck on what is probably a simple task.
I want to make an extra sensor to show the difference between my Solar and my Grid power. This is what I have done so far following different guides, but i get nothing back.

# Calculate Power Now   
  - platform: template
    sensors:
      energy_now:
        entity_id:
          - sensor.shelly_shem_6eaa27_1_current_consumption
          - sensor.shelly_shem_6eaa27_2_current_consumption
        value_template: >-
          {% set solar = states.sensor.shelly_shem_6eaa27_1_current_consumption.state|float %}
          {% set grid = states.sensor.shelly_shem_6eaa27_2_current_consumption.state|float %}    
          {{ (grid - solar)|round(1) }}

Any help would be greatly appreciated.

Welcome. Could you please format your pasted sensor config as per point 11 here: How to help us help you - or How to ask a good question