#Remember esp's global variables upon reflashing

1 messages · Page 1 of 1 (latest)

snow mason
#

Is it possible to program my esp8266 with esphome so that when flashing a new update, the global variables persist?

I control an espresso machine and I'm counting the number of shots pulled but it resets to 0 (and will reset to 0 at every reset). I also have sliders to fine tune the desired parameters that also get reset to their default position

here's my relevant snippet of code

globals:
  - id: shots_pulled
    type: int
    restore_value: yes
    initial_value: '0'

number:
  - platform: template # Home assistant widget to set target pressure 
    id: target_pressure
    name: Target Pressure
    min_value: 0
    max_value: 2
    initial_value: 0.95
    step: 0.01
    optimistic: true
    restore_value: true
    unit_of_measurement: "bar"
    icon: "mdi:kettle-alert"

  - platform: template # Home assistant widget to set target temperature 
    id: target_temperature
    name: Target Temperature
    min_value: 70
    max_value: 100
    initial_value: 85
    step: 1
    optimistic: true
    restore_value: true
    unit_of_measurement: "°C"
    icon: "mdi:thermometer-check"
#

actually I didn't set restore_from_flash, which may or may not be why it happened

#

no, same behavior with restore_from_flash set to true

lone elm
snow mason
#

oh also I see that not only there's a esphome discord server, I'm already a member on it. Is this a question best asked there?

lone elm
#

yeah you will probably get some more info there as they will know more. but as a home assistant solution if the settings can be set in HA then you could create a scene with the entities in it before you update. then restore the scene once complete? it would add an extra step to your update process and it feels messy though

#

but definitely ask over on esphome discord. there are probably tricks that i dont know about

snow mason
#

in that case I'd probably just update the initial values in the .yaml before updating

#

but that's pretty hacky, I don't love it

#

but thank you, if nothing else the counter thing will come in handy