Multiply with a sensor problem

I found a couple of examples on the forum but I can’t get it to work.
I want to calculate the euros I make with a solarpanel sensor.
The sensor on my device is: sensor.today_s_pv_generation
I tried with making a template sensor with the tarif. That didn’t work.
Now I made a template sensor: 0.39 is the Kwh price.

- platform: template
  sensors:
    panelen_schuur_dag_opbrengst:
      friendly_name: "Opbrengst per dag panelen schuur [EUR]"
      unit_of_measurement: "EUR"
      value_template: "{{ states('sensor.today_s_pv_generation') | float * states('0.39') | float }}"

I get the following log:

Logger: homeassistant.helpers.template_entity
Source: helpers/template_entity.py:364
First occurred: 20:39:05 (1 occurrences)
Last logged: 20:39:05

TemplateError('ValueError: Template error: float got invalid input 'unknown' when rendering template '{{ states('sensor.today_s_pv_generation') | float * states('0.39') | float }}' but no default was specified') while processing template 'Template<template=({{ states('sensor.today_s_pv_generation') | float * states('0.39') | float }}) renders=4>' for attribute '_attr_native_value' in entity 'sensor.panelen_schuur_dag_opbrengst'

apparently returned ‘unknown‘, which results in an error, as there is no default specified (which could be achieved by using float(0))
But the default is besides the point, you should try to find out why it returns “unknown“.
I suggest you use the template editor in developer tools, and find out😉

PS, states('0.39') doesn’t make sense either…
try this:
{{ states('sensor.today_s_pv_generation') | float(0)*0.39}}

Thanks,

That was it, it’s working now. One more question. The output is now: 0.117. I want to round this to 2 decimals. Tried value_template: “{{ states(‘sensor.today_s_pv_generation’) | float(0)*0.39|round(2) }}”
But that didn’t work. Do you know how?

{{(states(‘sensor.today_s_pv_generation’) | float(0)*0.39)|round(2) }}

Thanks again.