Compare debian version

Hello,

I have an automation, where I compare the debian version on my host and on the internet. If the version is different, I want to notify me.
It’s not difficult, but my automation doesn’t work. My debian version isn’t the same version with internet, but it’s never notify.
This is my automation :

- alias: Compare Debian Version
  initial_state: true
  trigger:
    platform: time
    at: "03:00:00"
  condition:
    condition: template
    value_template: "{{ states('sensor.current_debian_version.state') != states('sensor.installed_debian_version.state') }}"
  action:
    service: persistent_notification.create
    data:
      title: "Debian Version"
      message: "Please upgrade your Debian Version"

When I put my “value_template” in the template service in HA, the result is “True”.

Thank you

I sincerely doubt that. You must be putting something slightly different in the Template Editor to get True.

The states() function takes an entity_id as its parameter. Neither 'sensor.current_debian_version.state' nor 'sensor.installed_debian_version.state' are entity_id’s. Therefore both calls to states() should be returning 'unknown', and 'unknown' != 'unknown' will always evaluate to False.

You need to remove .state to get entity_id’s:

- alias: Compare Debian Version
  initial_state: true
  trigger:
    platform: time
    at: "03:00:00"
  condition:
    condition: template
    value_template: "{{ states('sensor.current_debian_version') != states('sensor.installed_debian_version') }}"
  action:
    service: persistent_notification.create
    data:
      title: "Debian Version"
      message: "Please upgrade your Debian Version"

Really ? Why ? This my result (I upgrade my debian in the meantime, but I have the same with HA in my screenshot). The result is True or False when I write that.

I forgot to remove, but it’s the same.

Do you know how is the best way to do that ?

I am not following you.

So looking at the results in your Template Editor, I agree they look correct.

But what is in your configuration now (for these automations)? And how are you determining if they work or don’t work? Are you waiting for 3:00 in the morning to come around? Or are you trying to manually trigger them? If the latter, please note that when you do that the triggers and conditions are ignored and it simply runs the action section of the automation.

Sorry if you don’t understand : I’m looking for a solution to notify me, at 3 am to notify me when the debian version is different between my version and the available version.

In my configuration, I have this automation :

- alias: Compare Debian Version
  initial_state: true
  trigger:
    platform: time
    at: "03:00:00"
  condition:
    condition: template
    value_template: "{{ states('sensor.current_debian_version') != states('sensor.installed_debian_version') }}"
  action:
    service: persistent_notification.create
    data:
      title: "Debian Version"
      message: "Please upgrade your Debian Version"

But this automation doesn’t work, that is to say, I don’t have notification when my version isn’t the same. You can see above, my value sensors is correct, but I think my condition isn’t good.

Well, I don’t see anything wrong with your automation.

I see that its initial state is on, but can you check, just to make sure, that it is indeed on?

Also, what happens when you manually trigger the automation? Do you get the notification?

You said earlier that you upgraded the OS and now the currently installed version is the same as the latest available version. If that is still the case then obviously it won’t cause a notification now. Also, when the versions were different, the automation wasn’t correct, so that’s why you didn’t get a notification before. But you’re saying it still doesn’t work. But how do you know that? What have you done to try and test the automation, as it currently exists, such that it should cause a notification (because right now, even though it looks correct, it shouldn’t cause a notification because the currently installed version isn’t different from the latest available version.)