Help! Is it possible to calculate the percentage of current power consumption?

Hello
Im new to HA, and find it verry interesting, (Dont understand much of YAMAL)
Im trying to track diffenent power consumptions with smart plugs now only got one innstalled.
I got my current power consumption in W
and i got a smartplug in my office.
Can i get this office sensor to say 24.66%?
And is it possible to get one meter that have the remaining % that i cant read by smart plugs? like 75.34%?

You can create two new template sensors for that.
https://www.home-assistant.io/integrations/template/

Please use the code-tags (</>) instead of an image and copy the yaml

template:
  - sensor:
      - name: "Kontor verbruk
        unit_of_measurement: "%"
        state: >
          {% set total = states('sensor.tiurvegen_1b') | float %}
          {% set study = states('sensor.smart_plug_kontor_kraft') | float %}
          {{ ((study/total) * 100) | round(1, default=0) }}
  - sensor:
      - name: "Rest verbruk
        unit_of_measurement: "%"
        state: >
          {% set study = states('sensor.kontor_verbruk') | float %}
          {{ (( 100-study ) | round(1, default=0) }}

Adjust the sensor names and number of digits as needed.
The {% … %} is a calculation or something.
The {{ … }} part is actually inserted into the sensor data.

Thank you som much @GH2user
Igot the firt part/templet to work.

Last part i get error.

invalid template (TemplateSyntaxError: unexpected ‘}’, expected ‘)’)

      {% set study = states('sensor.kontor_forbruk') | float %}
      {{ (( 100-study ) | round(1, default=0) }}

Any idea what i do wrong?

Oops, my bad I missed a )

      {{ (( 100 - study ) | round(1, default=0)) }}

You can also test them in the “Developer Tools” “Template” section. where it will give an error ) is expected. Whcih ytou most likely already did looking at your comment.

1 Like

Thank you very much @GH2user.

I tried another thing i can’t figure out, thought it should be easier.
To have the untraceable consumption in kWH. Not sure what makes this percent.

{% set study = states(‘sensor.kontor_forbruk’) | float %}
{{ (( 100-study ) | round(1, default=0) }}

We calculated the precentage of the study in the first sensor.
In the second sensor we substracted 100%-the first sensor percentage.
If you wan W then just use the same as in the first sensor for the total and study variables and substract these instead of (100-study) = (total-study).

For kWh you need a different sensor which might be available already or create it using the RIemann Helper sensor. An example of that is on this page at teh bottom https://www.home-assistant.io/integrations/integration/