I need to maintain a text_sensor value over reboot.
I have a global: (the initial value is arbitrary)
- id: last_feed_time_text
type: char[17]
restore_value: yes
initial_value: "{'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q'}"
…and want to update it using this:
- text_sensor.template.publish: # Publish feed time to HA
id: last_feed
state: !lambda |-
char str[17];
time_t currTime = id(on_board_time).now().timestamp;
strftime(str, sizeof(str), "%Y-%m-%d %H:%M", localtime(&currTime));
return { str };
- globals.set: # Store calculated hopper weight after feed
id: last_feed_time_text
value: !lambda 'return id(last_feed);'
The text_sensor.template.publish:
works fine.
When I add the globals.set
, it passes validation but fails to compile, delivering errors like below.
src/esphome/core/helpers.h:248:5: error: function returning an array
T value(X... x) {
^
src/esphome/core/helpers.h:263:5: error: function returning an array
T value_or(X... x, T default_value) {
^
src/esphome/core/helpers.h:278:26: error: function returning an array
std::function<T(X...)> f_;
Is what I’m trying possible? If yes, where am I going wrong?