Does <device>.latestValue() query the device or just the Hub -- battery usage concerns

I am looking to schedule logging of the status of a battery powered device, but do not want to drain the battery by asking the device every time. Will using .latestValue() be answered by the Hub based on the most recently reported state, or will the hub actively query the physical device for the state?

I am looking to create graphs (using Kibana) of the temperatures inside my house that the temperature sensors report. However, they only report on a state change (as expected), so there are gaps in the logs when there is no change of temperature. I want to report to the logging server (logstash) on a regular interval what the current temperature is, so there are no gaps in the graphs. I have no issues with polling a wired temperature sensor (like a thermostat), but I am concerned about draining the battery on battery powered device.

I have checked the Devices documentation page, but it does not mention if the physical device is queried, or just the most recent value is returned.

The exact code I am running is the following:

temperatureDeviceStateValue = temperature_sensor.latestValue("temperature")

Thank you

1 Like

Here’s a quick reference. If you request an attribute value (like you are above) it will pull the latest value stored locally from the hub (or from the cloud).

If you run a command, you may or may not query the device (depends on the command) which could affect battery life.

I normally use currentValue("")