diff --git a/HISTORY.md b/HISTORY.md index 94e80f99..73d98af9 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -16,7 +16,7 @@ - [MQTT Doc](https://github.com/TD22057/insteon-mqtt/blob/master/docs/mqtt.md) - note the new set_flags options for IOLinc and the IOLinc section - - A new queueing system for battery devices ([PR240][P240]): +- A new queueing system for battery devices ([PR240][P240]): - Messages sent to the device will be queued until the device is awake - When the device sends a message, the modem will attempt to immediately send the oldest outgoing message. This only works for some devices. @@ -26,6 +26,10 @@ ### Fixes +- Database delta is updated on database writes. This eliminates a number of + unnecessary refresh requirements, particularly around pairing. + ([PR 248][P248]) + ## [0.7.3] Fixing a number of small bugs in preparation for upcoming releases which @@ -429,3 +433,4 @@ will add new features. [P237]: https://github.com/TD22057/insteon-mqtt/pull/227 [P197]: https://github.com/TD22057/insteon-mqtt/pull/197 [P240]: https://github.com/TD22057/insteon-mqtt/pull/240 +[P248]: https://github.com/TD22057/insteon-mqtt/pull/248 diff --git a/insteon_mqtt/db/Device.py b/insteon_mqtt/db/Device.py index 8557247d..1acc6d7b 100644 --- a/insteon_mqtt/db/Device.py +++ b/insteon_mqtt/db/Device.py @@ -184,6 +184,7 @@ def set_delta(self, delta): """ self.delta = delta if delta is not None: + self.delta = self.delta % 256 # Roll over db if it goes past 256 self.save() #----------------------------------------------------------------------- diff --git a/insteon_mqtt/db/DeviceModifyManagerI1.py b/insteon_mqtt/db/DeviceModifyManagerI1.py index e1948b2f..7cdaa101 100644 --- a/insteon_mqtt/db/DeviceModifyManagerI1.py +++ b/insteon_mqtt/db/DeviceModifyManagerI1.py @@ -151,6 +151,22 @@ def handle_lsb_response(self, msg, on_done): else: self.advance_lsb(on_done) + #------------------------------------------------------------------- + def handle_lsb_write_response(self, msg, on_done): + """Handle Write of LSB + + This is only used to increment the delta for this device. + + Args: + msg: (message.InpStandard) The lsb message reply. The lsb data + is in the msg.cmd2 field. + on_done: (callback) a callback that is passed around and run on the + completion of the modification + """ + # Increment the delta 1 + self.db.set_delta(self.db.delta + 1) + self.handle_lsb_response(self, msg, on_done) + #------------------------------------------------------------------- def write_lsb_byte(self, on_done): """Writes the next byte in the record to the device. @@ -165,7 +181,7 @@ def write_lsb_byte(self, on_done): db_msg = Msg.OutStandard.direct(self.db.addr, 0x29, self.record[self.record_index]) msg_handler = handler.StandardCmd(db_msg, - self.handle_lsb_response, + self.handle_lsb_write_response, on_done=on_done, num_retry=self._num_retry) self.device.send(db_msg, msg_handler) diff --git a/insteon_mqtt/handler/DeviceDbModify.py b/insteon_mqtt/handler/DeviceDbModify.py index 9e2a3691..5c530167 100644 --- a/insteon_mqtt/handler/DeviceDbModify.py +++ b/insteon_mqtt/handler/DeviceDbModify.py @@ -72,6 +72,8 @@ def msg_received(self, protocol, msg): # entry, or an marked unused (deletion). LOG.info("Updating entry: %s", self.entry) self.db.add_entry(self.entry) + # Increment the delta 1 + self.db.set_delta(self.db.delta + 1) self.on_done(True, "Device database update complete", self.entry)