Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increment Database Delta on Writing #248

Merged
merged 3 commits into from
Dec 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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
1 change: 1 addition & 0 deletions insteon_mqtt/db/Device.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

#-----------------------------------------------------------------------
Expand Down
18 changes: 17 additions & 1 deletion insteon_mqtt/db/DeviceModifyManagerI1.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions insteon_mqtt/handler/DeviceDbModify.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down