Var custom_component retains old value

Hi,

Having a problem with snarky_snark’s “var” custom_component. I have it installed to track version numbers of modules/packages I write which then get displayed on my dashboard. I was using rogro82’s “variable” component but have recently changed to this one.

At the top of each package I have something like:

var:
  phones_as_webcams_version:
    friendly_name: "Phones as Webcams version"
    initial_value: "v1.15 (11/06/2021)"
    icon: mdi:history

When I make a code change I update the version and date. With the old “variable” component the new value was accepted and duly displayed. Since switching to snarkysnark’s “var” component the variable doesn’t change even though initial_value is used to set it.

I’ve tried adding:

tracked_event_type: homeassistant_start

but it makes no difference.

What am I doing wrong?

I’ve learned so much from these forums since starting to use HA at the beginning of the year. Hoping someone will come up with the answer to this. I really don’t want to have to use “input_text” as “var” is perfect for storing this kind of information.

Cheers
Rich

Anyone have any ideas on this please…?

Contact the custom component’s author by posting an Issue in their GitHub repository:

The solution was to use:

restore: false

so it doesn’t use the previously stored value. Initial_value is only evaluated once upon creation and by default the value is restored from the DB (ie restore: true).

Potentially meaning that home-assistant-variables is no longer capable of restoring a value from the database due to recent changes in Home Assistant’s database. This has happened in the past and the author updated the software (and might have to update it again).

I think it was just me not using the component properly. The restore feature is documented but I didn’t realise its importance and didn’t try it.
I naively (and incorrectly) assumed that if I set a new initial_value it would be used but the component doesn’t work like that. Initial_value is only evaluated once.