Pyscript - new integration for easy and powerful Python scripting

I see that pyscript.some_name is easily accessible in lovelace so no need to set a sensor.some_name in addition to pyscript.some_name.

The code I ended up with is shown below and is a bit shorter than the appdaemon code. Mainly because of the timer handling in appdaemon, but also because it is easier to maintain state in pyscript, it seems.

state.persist('pyscript.total_pris_for_strom', default_value=0, default_attributes={"unit_of_measurement":"NOK"})

@time_trigger("cron(59 * * * *)")
def akkumulere_stromkostnad():
    p = round(float(sensor.total_electricity_price) * float(sensor.estimated_hourly_consumption) + float(pyscript.total_pris_for_strom), 2)
    pyscript.total_pris_for_strom = p

@time_trigger("cron(0 0 * * *)")
def nullstille_stromkostnad():
    pyscript.total_pris_for_strom = 0