Hey!
I have a problem with the “value_template” synthax.
I have a sensor which tell me a unit and a sensor which tell me a value.
In the sensor which Tell me the value I want to make a if than else:
If
the unit is “kWh” than use the value
Else
Use the value and divide the value with 1000
End if
Here is my try:
- platform: scrape
resource: "https://www.sunnyportal.com/Templates/PublicPage.aspx?page=7431e23c-a310-4fdf-99ec-e31db735d65f"
name: pv_unit
select: '#ctl00_ContentPlaceHolder1_PublicPagePlaceholder1_PageUserControl_ctl00_PublicPageLoadFixPage_energyYieldWidget_energyYieldUnit'
- platform: scrape
resource: "https://www.sunnyportal.com/Templates/PublicPage.aspx?page=7431e23c-a310-4fdf-99ec-e31db735d65f"
name: pv_value
select: '#ctl00_ContentPlaceHolder1_PublicPagePlaceholder1_PageUserControl_ctl00_PublicPageLoadFixPage_energyYieldWidget_energyYieldValue'
value_template: '{% if is_state("sensor.pv_unit", "kWh") %}states.sensor.pv_value{% else %}states.sensor.pv_value/1000{% endif %}'
unit_of_measurement: 'KW/h'
But as the result I get the text “states.sensor.pv_value” not the value or if the Unit is not kWh the value/1000
Can someone help me with the synthax?
Thank you