Closed
Description
I have this definition
@state_trigger("sensor.grid_consumed_energy_hour")
def accumulate_purchased_cost_daily(value,old_value):
log.info(f"got arguments {value} {sensor.electricity_price}" )
temp = float(input_number.accumulate_purchased_cost) \
+ (float(sensor.electricity_price)*(abs(float(value)-float(old_value))))
state.set('input_number.accumulate_purchased_cost',temp)
This works for a while but after 1-2h I get "maximum recursion depth exceeded in comparison". I can't find the place where I have introduced a recursion call.
I have also tried
input_number.accumulate_purchased_cost = float(input_number.accumulate_purchased_cost) \
+ (float(sensor.electricity_price)*(abs(float(value)-float(old_value))))
but the result is the same. Any insight what I have done wrong is appreciated.
Pyscript version: 0.32
debug log:
2020-11-09 18:40:00 DEBUG (MainThread) [custom_components.pyscript.state] state.update({'sensor.grid_consumed_energy_hour': '0.90', 'sensor.grid_consumed_energy_hour.old': '0.89'}, {'trigger_type': 'state', 'var_name': 'sensor.grid_consumed_energy_hour', 'value': '0.90', 'old_value': '0.89'})
2020-11-09 18:40:00 DEBUG (MainThread) [custom_components.pyscript.trigger] trigger file.energy.accumulate_purchased_cost_daily got state trigger, running action (kwargs = {'trigger_type': 'state', 'var_name': 'sensor.grid_consumed_energy_hour', 'value': '0.90', 'old_value': '0.89'})
2020-11-09 18:40:00 DEBUG (MainThread) [custom_components.pyscript.trigger] trigger file.energy.accumulate_purchased_cost_daily waiting for state change or event
2020-11-09 18:40:00 DEBUG (MainThread) [custom_components.pyscript.eval] file.energy.accumulate_purchased_cost_daily: calling info("got arguments 0.90 1.059", {})
2020-11-09 18:40:00 INFO (MainThread) [custom_components.pyscript.file.energy.accumulate_purchased_cost_daily] got arguments 0.90 1.059
2020-11-09 18:40:00 DEBUG (MainThread) [custom_components.pyscript.eval] file.energy.accumulate_purchased_cost_daily: calling float("5.332900000000042", {})
2020-11-09 18:40:00 DEBUG (MainThread) [custom_components.pyscript.eval] file.energy.accumulate_purchased_cost_daily: calling float("1.059", {})
2020-11-09 18:40:00 DEBUG (MainThread) [custom_components.pyscript.eval] file.energy.accumulate_purchased_cost_daily: calling float("0.90", {})
2020-11-09 18:40:00 DEBUG (MainThread) [custom_components.pyscript.eval] file.energy.accumulate_purchased_cost_daily: calling float("0.89", {})
2020-11-09 18:40:00 DEBUG (MainThread) [custom_components.pyscript.eval] file.energy.accumulate_purchased_cost_daily: calling abs(0.010000000000000009, {})
2020-11-09 18:40:00 DEBUG (MainThread) [custom_components.pyscript.eval] file.energy.accumulate_purchased_cost_daily: calling set("input_number.accumulate_purchased_cost", 5.343490000000042, {})
2020-11-09 18:40:00 DEBUG (MainThread) [custom_components.pyscript.state] setting input_number.accumulate_purchased_cost = 5.343490000000042, attr = {'initial': None, 'editable': False, 'min': 0.0, 'max': 10000000.0, 'step': 1.0, 'mode': 'slider', 'unit_of_measurement': 'SEK', 'icon': 'mdi:cash'}
2020-11-09 18:40:00 ERROR (MainThread) [custom_components.pyscript.file.energy.accumulate_purchased_cost_daily] Exception in <file.energy.accumulate_purchased_cost_daily> line 14:
state.set('input_number.accumulate_purchased_cost',temp)
^
RecursionError: maximum recursion depth exceeded in comparison
Metadata
Metadata
Assignees
Labels
No labels