Automation using template and 2 values not equal to each other

Hi there

I’m trying to setup an automation to notify me when 2 values are not equal, I have checked the values under developer tools and they are different (35 & 50) so it should run but the automation is not working and I’m not sure why, any help would be greatly appreciated.

Thanks in advance.

alias: ESS SOC differs from ESS input select value
description: ""
trigger:
  - platform: time
    at: "08:00:00"
condition:
  - condition: template
    value_template: >-
      "{{ states('input_select.victron_ess_minimum_soc') !=
      states('sensor.ess_minimum_soc') }}"
action:
  - service: notify.mobile_app_paul_s21
    data:
      message: >-
        ESS SOC differs from ESS input select value (select desired value from
        drop down)
      title: ESS Missmatch
mode: single

I have also tried

alias: ESS SOC differs from ESS input select value
description: ""
trigger:
  - platform: time
    at: "08:00:00"
condition:
  - condition: template
    value_template: >-
      "{{ states('input_select.victron_ess_minimum_soc')|float !=
      states('sensor.ess_minimum_soc')|float }}'
action:
  - service: notify.mobile_app_paul_s21
    data:
      message: >-
        ESS SOC differs from ESS input select value (select desired value from
        drop down)
      title: ESS Missmatch
mode: single

What are the expected values? Numbers or strings? You might have a conversion issue.
Try to see the result of those two select on the tab Templates under Developer tools.

Or if you are expecting numbers, you can try something like this:

    value_template: >-
      "{{ states('input_select.victron_ess_minimum_soc') | float !=
      states('sensor.ess_minimum_soc')  | float }}"
1 Like

They are numbers

I did try this but it didn’t work

  "{{ states('input_select.victron_ess_minimum_soc')|float !=
  states('sensor.ess_minimum_soc')|float }}'

Go to Developer tools, select the Template tab and paste this over there:

{{ states('input_select.victron_ess_minimum_soc') | float }}
{{ states('sensor.ess_minimum_soc') | float }}

Please let me know the results on the box in the right.

Hi there

Please see attached

And what if you try your code on that Template tab? Are you getting “false”?

I believe we have something else here…

When you say “but it didn’t work”, what that means and how are you testing it?

If you are using the automation as it is, it won’t be triggered until 08:00AM, if you are running the automation manually, it will ignore all the conditions anyways…
If you go to the automation in the UI, you will be able to click on “Test” to verify if the conditions are being evaluated correctly.

OK I found the issue, my template had a " at the beginning and a ’ at the end which is why it was failing.

Thanks for your help you got me headed off in the right direction, when I ran my template under developer tools it came back with True and the single quote at the end.

1 Like