Qbhatti
November 23, 2022, 10:29am
1
Hi
I have something fairly basic to do, but I cant get my head around it.
I have 2 sensors I need to multiply, and divide by 10.
so:
sensor.solis_mqtt_dc1_voltage
sensor.solis_mqtt_dc1_current
voltage 1 is x10 though.
‘’’
-name: “MQTT PV1 power”
value_template: "{{states(‘sensor.solis_mqtt_dc1_voltage’) / 10 ) | float} x states(‘sensor.solis_mqtt_dc1_current’) | float}}
‘’’
but it wont work - i dont get it!
help would be appreciated, as I dont seem to be able to pull the actual power from the inverter through mqtt.
123
(Taras)
November 23, 2022, 12:35pm
2
If you are trying to create a Template Sensor that performs a calculation using the values of other sensors, you can do it like this:
template:
- sensor:
- name: "MQTT PV1 power"
state: "{{ (states('sensor.solis_mqtt_dc1_voltage') | float(0) / 10) * states('sensor.solis_mqtt_dc1_current') | float(0) }}"
Reference: Template Sensor
EDIT
Correction. Added missing {{
to template.
1 Like
Qbhatti
November 23, 2022, 2:30pm
3
Hi thanks for that.
Ive put that in, but it doesnt actually do the calculation for me: it just says that string as the value.
123
(Taras)
November 23, 2022, 3:10pm
4
That’s due to my mistake. I overlooked to include {{
in the template. Without it, it’s not evaluated as a Jinja2 template but merely as a string. I have corrected the example above.
1 Like