Changing the power consumed by heating coil by calling URLs

Hi, I want to control our PWM device based on the status of the incoming Solar Power.
To control the Heating coil i have to open the URL with the internal Ip followed by /?watt=50.
This will result in 50 percent of the power from the heating coil.

so in the automation i would have to do some maths to just use the power coming from the solarpanels.
after the maths it should call the URL.

Can anybody give me a hint where i should dig into? i have no idea where to start!

First configure a REST command: RESTful Command - Home Assistant
You can use variables, so a configuration could look like:

rest_command:
  set_power:
    url: "http://internal_ip/?watt={{power}}"

In the automation you call the service like this:

service: rest_command.set_power
data:
  power: 50

Instead of the number you can use a template to do the calculation.

1 Like

Thank you very much. From what i can see this did the trick for me ( tested in Dev Options ). I will wait for the next day. I changed to measuring with my home shelly 3em, when theres negative consumption and i wanted to have a maximum of 75 percent usage of the heating coil.

The code looks like this right now:

service: rest_command.set_power_heizstab
data:
  power: >-
    {% set p = states('sensor.hausverbrauchkomplett') | float  %} 
    {% if p >= 0 %}
      0
    {% elif p <= -1500 %}
      75
    {% else %}
      {{ (states('sensor.hausverbrauchkomplett') | float / 2000 * 100) | round(0) | abs }}
    {% endif %}

The only thing i dont really like is the need for that -1500 on elif, but i couldnt figure out how to do the measurement like on else.

Thanks!