snarky-snark / home-assistant-variables

A custom Home Assistant component for declaring and setting generic variable entities dynamically.
Apache License 2.0
276 stars 16 forks source link

Var custom_component retains old value #56

Closed richard-c-howlett closed 3 years ago

richard-c-howlett commented 3 years ago

Hi,

Having a problem with the “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 your one which appears to be a better component moving forward.

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 your “var” component the variable doesn’t change even though initial_value is used to set it. The very first setting of the variable remains.

I’ve tried adding:

tracked_event_type: homeassistant_start

in an attempt to force it to re-assign the initial_value but it makes no difference.

What am I doing wrong?

Cheers Rich

snarky-snark commented 3 years ago

Use value_template with the home_assisstant_start event. initial_value is only evaluated once in the life of the variable unless restore is set to false. You could try that as well.

richard-c-howlett commented 3 years ago

Thank you for reply.

I decided to use "restore: false" and it now works exactly as intended. I did see the restore option in the configuration guide but it didn't twig that using it would fix the issue! Anyway all working now - thank you.

Cheers Richard

On Thu, 1 Jul 2021 at 15:13, snarky-snark @.***> wrote:

Use value_template with the home_assisstant_start event. initial_value is only evaluated once in the life of the variable unless restore is set to false.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/snarky-snark/home-assistant-variables/issues/56#issuecomment-872282582, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQYSTAB34BEJTIDJYKANOT3TVRZV7ANCNFSM47UW226Q .

snarky-snark commented 3 years ago

Great!