I am using pyscript for an equivalent of 'state based template entities'.
state.persist('pyscript.sensor_mydouble')
# "template sensor that doubles the original value"
@state_trigger('sensor.mysensor')
def mydouble_on_value_change():
pyscript.sensor_mydouble = 2 * sensor.mysensor
I also need to take some temporary attributes from the original entity that are only used for calculations:
@state_trigger('sensor.mysensor.data')
def mydouble_on_attr_change():
# attribute data contains only auxiliary data
# that souldn't be recorded
try:
data = [ d.copy() for d in sensor.mysensor.data ]
for elem in data:
elem['price'] *= 2
except Exception as e:
data = None
pyscript.sensor_mydouble.data = data
Hi!
I am using pyscript for an equivalent of 'state based template entities'.
I also need to take some temporary attributes from the original entity that are only used for calculations:
Those attributes shouldn't be archived in recorder history: https://developers.home-assistant.io/docs/core/entity/#excluding-state-attributes-from-recorder-history
It would be nice if pyscript would support that.
Cheers, --leo