Is it possible to test on a global Var value before last change?

I like to test on a global.var before the last change.
So if the last var before change is 0 and it is now 3, I like to know that the last value was 0.

Is this possible in NodeRED?
Or do I need to make a var for the last status?

You can always test a global variable before you change it. or you can create one that holds two values like this:

var blah = { oldvar: “foo”, newvar: “bar”}

then you would save it as a global, and each time you change it you would retrieve it from global, assign newvar to oldvar and then assign your new value to newvar.

You are talking about storing state information and you have an embarrassing number of options. You could write them to:

  • The HA db itself (not advised)
  • A file
  • A DB - sqlite or MariaDB, Postgres
  • A MQTT message
  • Send an email and read back via IMAP from a mailbox

For my money MQTT is the best bet. If you have HA and Node Red then you really should have MQTT running as well and pointing MQTT Explorer at it is so easy to watch what is going on, on the fly.

A file is prone to locking snags and a db may be too much “stuff”.