There seems to be some confusion with the documentation that is on the HA website IoTaWatt intergration.
The sensors mainsexport and mainsconsumption are just examples. These examples are based on the other example that is shown on the website that creates two Outputs in the IoTaWatt web interface.
I didn’t author the website, but am trying to put something together this weekend.
This gist is if you are running HA 2021.9.0 (or 2021.9.1 as of today) and using the official integration (not the HACS integration) and if you have one IoTaWatt input monitoring a circuit that is for your solar panels, this circuit is doing both importing and exporting energy. This means positive and negative values could be sent from IoTaWatt to Home Assistant. To mitigate this issue the user first needs to configure two Outputs in the IoTaWatt web interface, as is shown in the graphic in the link I referenced above. Then from in Home Assistant you need to create two sensors, this is where mainsexport and mainsconsumption comes to light. If you followed the example and named the Outputs in IoTaWatt as per the example they need to match in the configuration in Home Assistant. If you named the Outputs differently then well use your names.
Now the above is if you have solar. If you don’t have solar, not monitoring solar, or monitoring solar but don’t have both import and export energy through a single CT clamp (Input) attached to an IoTaWatt then you can ignore the above. But there is more!
Now for any sensors (Input or Output) from the IoTaWatt with a unit type of Watts that you want Home Assistant to use in the Energy Dashboard you have to create an entry in your configuration for each sensor. If you have a total of 30 sensors you need to create 30 entries.
In your case from your template file I assume you have a sensor named sensor.ac. This should be the sensor from the IoTaWatt but with a type of Watts You would need to add this entry (you can change the Name to whatever you want I just gave it Main AC) in your configuration file to have the Energy Dashboard accept it.
sensor iotawatt:
- platform: integration
source: sensor.ac
name: Main AC
unit_prefix: k
If you actually don’t have sensors with the name of sensor.mainsexport or sensor.mainsconsumption you can remove those from your config.
I know this is very long! And I’m sorry but some things are out of my control. Anyway I have released a beta release of the HACS custom_component for IoTaWatt that supports HA 2021.9. Still be tested but it only needs a sensors added to the configuration if you have solar and need to split the import and export into seperate sensors.