#Persistent storage of a value
1 messages · Page 1 of 1 (latest)
Any of the helpers
Sorry, I don't understand. I've looked at helpers (input numbers and template sensors), but that doesn't seem to be what I need.
Input numbers seem to require maximum and minimum values and template sensors some type of value template. I don't want to set a maximum and I don't know what value template to use. I just want to store a value persistently (including beyond a reboot).
I don't know why it wants a min and max, but just give the biggest range
You can just ignore them
What is the range of an energy sensor in kWh?
So what is the range for if I can ignore it? Just to configure the slider for the GUI?
I've set up an input number now, but I'm having trouble setting up the action to write to it.
Adapting the solution from this post I added an action block:
- actions:
- action:
- variables:
target_charge: >-
{{ states('sensor.zb_plug_ts011fp3_20a_02_energy') | int(0) }}
- service: number.set_value
target:
entity_id: input_number.xxxenergyonpreviousrun
data:
value: '{{ target_charge }}'```
But it is giving me an error I don't know how to interpret:
> The automation "xxx" (automation.xxx) is not active because the configuration has errors.
>
> Error:value should be a string for dictionary value @ data['actions'][1]['action']. Got [{'variables': None, 'target_charge': "{{ states('sensor.zb_plug_ts011fp3_20a_02_energy') | int(0) }}"}, {'service': 'number.set_value', 'target': {'entity_id': 'input_number.xxxenergyonpreviousrun'}, 'data': {'value': '{{ target_charge }}'}}].
You need to indent the line under variables:
Number is not input_number
Seems like you're mixing them up
Thanks, yeah, I didn't realize number and input_number are different animals...
- action:
- service: input_number.set_value
data_template:
entity_id: input_number.xxxenergyonpreviousrun
value: "{{ states('sensor.zb_plug_ts011fp3_20a_02_energy') }}"```
still gives me an error like above and I don't see where I'm going wrong with the indentation.
> Error:value should be a string for dictionary value @ data['actions'][1]['action']. Got [{'service': 'input_number.set_value', 'data_template': {'entity_id': 'input_number.xxxenergyonpreviousrun', 'value': "{{ states('sensor.zb_plug_ts011fp3_20a_02_energy') }}"}}].
Ah, thanks, now I get it. service is on the same level as action, both under actions.
action: replaced service: several releases ago