Novice Question - Updating Changed Device States
Posted: Sun Aug 27, 2023 9:07 am
My Life360 plugin appears to be working fine, but I recently discovered that I update every device state regardless of whether it's value has changed. I do this because I incorrectly assumed that Indigo magically handled that during state saving. The problem obviously is that triggers always think a device state has changed, and fire unnecessarily.
Currently I do the following:
1) Call the API for each device_id in updatedevicestates which is called in a loop for each device from runConcurrentThread at the frequency chosen in pluginProps
2) Get every state for that device from Life360 and save it in an array called device_states
3) Update all the device states
What's the right way to update only the device states that have changed?
Currently I do the following:
1) Call the API for each device_id in updatedevicestates which is called in a loop for each device from runConcurrentThread at the frequency chosen in pluginProps
- Code: Select all
def updatedevicestates(self, device):
2) Get every state for that device from Life360 and save it in an array called device_states
- Code: Select all
device_states.append({'key': 'member_first_name','value': m['firstName'] })
3) Update all the device states
- Code: Select all
device.updateStatesOnServer(device_states)
What's the right way to update only the device states that have changed?