What is the difference between Current State and State Variable in a driver?

I feel like this is a silly question but I can't find the answer anywhere. I have a Zooz 4-in-1 sensor and the current state temperature is much different from the state variable.

I can't figure out why these two numbers are different, and I also will admit that I have no idea what either of them means.

Should the two numbers be the same (assuming the temperature doesn't change over the course of an hour)?

What is the utility for each?

Can someone please explain? The screenshot will hopefully help. Thank you!

1 Like

Not necessarily. The "current state" is saved based on a report received from the device itself. The "state variables" are created and saved by the developer of the driver based on some logic, at some point in time. Also, the state variables persist if you change drivers, so the value of 69.50 that you see, may have been saved long time ago, and its value may not even be related to the current driver.

3 Likes

Thanks, @bobbyD that's helpful. In follow-up, does the state variable have any bearing on Brawl manager function or thermostat control or function?

I discovered this when I was trying to set up thermostat controller in preparation for warmer weather. I added the sensor since it’s in a bathroom on the top floor and just wanna make sure it’s not skewing the average temperature from all of the sensors.

Is it possible to confirm that only the current state temperature is used in thermostat controller logic as well as rule machine logic?

Also, is there anything I can do to correct the state variable number or is that even necessary? My OCD brain is not gonna let it go! :joy:

Any app can only use the current states of a device. The state variables are for informational purpose, and visible only for that driver.

1 Like

Apparently, developer's OCD brain had a reason to save the "reported value" in a variable for some reason. Depending on what driver you are using, the developer who created it, can provide an explanation why that value was important to be saved and posted on the Device Details page.

1 Like

There is a driver named "Clean Device" that when associated with a device can delete old state variables. It should be in the Hubitat area but if not I can post it. I believe it is by boristhecat.

Changing the driver to "Device" type would also allow you to delete old states, among other things.

Just IMO as a developer of a bunch of drivers... I often save many things the device reports to Current States but not as State Variables if I am not sure there is a demand/value for the information. Some things provide a TON of info that nobody cares about.

But, it is sometimes useful to have some of it displayed somewhere in case someone sees it and goes "I need that...". Then I can rev the driver and have it added as a State Variable. I also generally save anything I put as a State Variable in the current states so I can compare new data readily and decide if I need to pop an event because it changed (or not).

2 Likes

Thank you, I didn't realize the "Driver" would clear those data. I assume this was a update that I didn't read the change logs for.

John

That is probably the most common use of states in drivers. You can create a reference point of a status, at a certain time, for comparison purposes.

This topic has been marked solved by the community and subsequently closed.