Skip to content

Commit

Permalink
Merge branch 'dev' into Fix_250
Browse files Browse the repository at this point in the history
Fixed Conflicts:
	insteon_mqtt/db/Device.py
  • Loading branch information
krkeegan committed Dec 18, 2020
2 parents 4d9cfa8 + 085a68d commit 511a6d7
Show file tree
Hide file tree
Showing 47 changed files with 1,015 additions and 418 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.7.3
current_version = 0.7.4
commit = True
tag = False

Expand Down
45 changes: 45 additions & 0 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Linting and Pytest

on:
pull_request:
branches:
- dev

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if [ -f requirements-test.txt ]; then pip install -r requirements-test.txt; fi
- name: Lint with flake8 exit on errors
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 insteon_mqtt --count --select=E9,F63,F7,F82 --show-source --statistics
- name: Lint with flake8 warnings annotation
uses: TrueBrain/[email protected]
with:
path: insteon_mqtt
ignore: E265,E203,E123,E722,E127,E131,E731,W504
max_line_length: 79
only_warn: 1
- name: Test with pytest
run: |
# Skips creating coverage stats for covered items
pytest --cache-clear --cov-report term:skip-covered --cov=insteon_mqtt tests/ | tee pytest-coverage.txt
# - name: Comment coverage
# uses: coroo/[email protected]
# with:
# pytest-coverage: pytest-coverage.txt

17 changes: 17 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Revision Change History

## [0.7.5]

### Additions

### Fixes

- Improved message handling and processing of Pre_NAK messages.
([PR 236][P236])

## [0.7.4]

### Additions
Expand Down Expand Up @@ -40,10 +49,15 @@

### Fixes

- Major fixes to a number of bugs in the Scenes management functions.
(thanks @tstabrawa)([PR 234][P234])

- Database delta is updated on database writes. This eliminates a number of
unnecessary refresh requirements, particularly around pairing.
([PR 248][P248])

- Minor fix to the calculation of hops on resent messages. ([PR 259][P259])

## [0.7.3]

Fixing a number of small bugs in preparation for upcoming releases which
Expand Down Expand Up @@ -452,3 +466,6 @@ will add new features.
[P239]: https://github.com/TD22057/insteon-mqtt/pull/239
[P244]: https://github.com/TD22057/insteon-mqtt/pull/244
[P235]: https://github.com/TD22057/insteon-mqtt/pull/235
[P259]: https://github.com/TD22057/insteon-mqtt/pull/259
[P234]: https://github.com/TD22057/insteon-mqtt/pull/234
[P236]: https://github.com/TD22057/insteon-mqtt/pull/236
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ My initial intent with this package is better integrate Insteon into
Home Assistant and make it easier and more understandable to add new
features and devices.

Version: 0.7.3 ([History](HISTORY.md))
Version: 0.7.4 ([History](HISTORY.md))

### Breaking changes from last version:
### Recent Breaking Changes

- KeypadLinc now supports both dimmer and on/off device types. This required
- 0.7.4 - IOLinc, the scene_topic has been elimited, please see the documentation
for the replaces functionality.
- 0.7.2 - KeypadLinc now supports both dimmer and on/off device types. This required
changing the KeypadLinc inputs in the MQTT portion of the config.yaml file.
See the file in the repository for the new input fields. ([Issue #33][I33]).

Expand Down
15 changes: 10 additions & 5 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -851,8 +851,13 @@ mqtt:
# In Home Assistant use MQTT switch with a configuration like:
# switch:
# - platform: mqtt
# state_topic: 'insteon/aa.bb.cc/state'
# command_topic: 'insteon/aa.bb.cc/scene'
# state_topic: 'insteon/aa.bb.cc/relay'
# command_topic: 'insteon/aa.bb.cc/set'
#
# To monitor the sensor, use an MQTT binary_sensor with a configuration like:
# binary_sensor:
# - platform: mqtt
# state_topic: 'insteon/aa.bb.cc/sensor'
io_linc:
# Output state change topic and template. This message is sent whenever
# the device sensor or device relay state changes. Available variables for
Expand All @@ -864,7 +869,7 @@ mqtt:
# sensor_on_str = 'off'/'on'
# relay_on_str = 'off'/'on'
state_topic: 'insteon/{{address}}/state'
state_payload: '{ "sensor" : "{{sensor_on_str.lower()}}", "relay" : {{relay_on_str.lower()}} }'
state_payload: '{ "sensor" : "{{sensor_on_str.upper()}}", "relay" : {{relay_on_str.upper()}} }'

# Output relay state change topic and template. This message is sent
# whenever the device relay state changes. Available variables for
Expand All @@ -874,7 +879,7 @@ mqtt:
# relay_on = 0/1
# relay_on_str = 'off'/'on'
relay_state_topic: 'insteon/{{address}}/relay'
relay_state_payload: '{{relay_on_str.lower()}}'
relay_state_payload: '{{relay_on_str.upper()}}'

# Output sensor state change topic and template. This message is sent
# whenever the device sensor state changes. Available variables for
Expand All @@ -884,7 +889,7 @@ mqtt:
# sensor_on = 0/1
# sensor_on = 'off'/'on'
sensor_state_topic: 'insteon/{{address}}/sensor'
sensor_state_payload: '{{sensor_on_str.lower()}}'
sensor_state_payload: '{{sensor_on_str.upper()}}'

# Input on/off command. This forces the relay on/off and ignores the
# momentary-A,B,C setting. Use this to force the relay to respond.
Expand Down
2 changes: 1 addition & 1 deletion hassio/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Insteon MQTT",
"description": "Python Insteon PLM <-> MQTT bridge",
"slug": "insteon-mqtt",
"version": "0.7.3",
"version": "0.7.4",
"startup": "services",
"arch": ["amd64","armhf","aarch64","i386"],
"boot": "auto",
Expand Down
2 changes: 1 addition & 1 deletion insteon_mqtt/Protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ def _send_next_msg(self):
msg_bytes = out.msg.to_bytes()

LOG.info("Write message to modem: %s", out.msg)
LOG.debug("Write bytes to modem: %s", msg_bytes)
LOG.debug("Write bytes to modem: %s", msg_bytes.hex())

# Write the message to the PLM modem. The message will only be sent
# when the current time is after the next write time as tracked by
Expand Down
29 changes: 13 additions & 16 deletions insteon_mqtt/Scenes.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def compress_controllers(self):
controllers are merged.
This is a companion to compress_responders and compress_n_way. These
are seperate functions to that they can be called seperately using
are seperate functions so that they can be called seperately using
Stacks.
This function only processes the scenes in a single pass. If it runs
Expand Down Expand Up @@ -164,7 +164,7 @@ def compress_responders(self):
merged.
This is a companion to compress_controllers and compress_n_way.
These are seperate functions to that they can be called seperately
These are seperate functions so that they can be called seperately
using Stacks.
This function only processes the scenes in a single pass. If it runs
Expand Down Expand Up @@ -205,7 +205,7 @@ def compress_n_way(self):
definition..
This is a companion to compress_responders and compress_controllers.
These are seperate functions to that they can be called seperately
These are seperate functions so that they can be called seperately
using Stacks.
This function only processes the scenes in a single pass. If it runs
Expand Down Expand Up @@ -522,7 +522,7 @@ def from_link_entry(scene_manager, device, entry):
if not found_ctrl:
# We know nothing about the controller so set to default values
# the link-data may be wrong, but it doesn't seem to matter
if entry.group > 0x01:
if entry.group != 0x01:
scene['controllers'].append({entry_addr: entry.group})
else:
scene['controllers'].append(entry_addr)
Expand Down Expand Up @@ -731,16 +731,13 @@ def __eq__(self, other):
primarily by the compress_* functions
'''
ret = False
self_group = self.group if self.group > 0x00 else 0x01
other_group = other.group if other.group > 0x00 else 0x01
if (self.addr == other.addr and self_group == other_group and
if (self.addr == other.addr and self.group == other.group and
self.link_data == other.link_data):
ret = True
return ret

def __str__(self):
self_group = self.group if self.group > 0x00 else 0x01
subs = (self.addr, self_group, self.link_data)
subs = (self.addr, self.group, self.link_data)
return 'Dev Addr: %s Group: %s Data1-3: %s' % subs

def __hash__(self):
Expand Down Expand Up @@ -822,20 +819,20 @@ def group(self, value):
Args:
value: (int)The group value
"""
if self.style == 0 and value > 0x01:
if self.style == 0 and value != 0x01:
if ('group' not in self._yaml_data[self.label] or
self._yaml_data[self.label]['group'] != value):
self._yaml_data[self.label]['group'] = value
if self.style == 1 and value > 0x01:
if self.style == 1 and value != 0x01:
self._yaml_data[self.label] = value
if self.style == 2 and value > 0x01:
if self.style == 2 and value != 0x01:
self._yaml_data = {self.label: value}

# Remove group entry in yaml_data if default value of 0x00 or 0x01
# Remove group entry in yaml_data if default value of 0x01
if (self.style == 0 and 'group' in self._yaml_data[self.label] and
value <= 0x01):
value == 0x01):
del self._yaml_data[self.label]['group']
elif self.style == 1 and value <= 0x01:
elif self.style == 1 and value == 0x01:
self._yaml_data = self.label
self.update_device()

Expand Down Expand Up @@ -891,7 +888,7 @@ def link_data(self):
# Group is a bit special and gets added to link_data
# a few responders (kpl) need to know group to set data_3
link_dict = self._yaml_data[self.label].copy()
if self.group > 0x01:
if self.group != 0x01:
link_dict['group'] = self.group
# Convert data values from human readable form
pretty_data = self.device.link_data_from_pretty(
Expand Down
2 changes: 1 addition & 1 deletion insteon_mqtt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
For docs, see: https://www.github.com/TD22057/insteon-mqtt
"""

__version__ = "0.7.3"
__version__ = "0.7.4"

#===========================================================================

Expand Down
4 changes: 3 additions & 1 deletion insteon_mqtt/cmd_line/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def pair(args, config):
if reply["status"]:
print("Pairing may fail if the modem db is out of date. Try running")
print("the following and then re-try the pair command.")
print(" insteont-mqtt config.py refresh modem")
print(" insteon-mqtt config.py refresh modem")

return reply["status"]

Expand Down Expand Up @@ -315,6 +315,7 @@ def import_scenes(args, config):
reply = util.send(config, topic, payload, args.quiet)
return reply["status"]


#===========================================================================
def awake(args, config):
topic = "%s/%s" % (args.topic, args.address)
Expand All @@ -325,6 +326,7 @@ def awake(args, config):
reply = util.send(config, topic, payload, args.quiet)
return reply["status"]


#===========================================================================
def get_battery_voltage(args, config):
topic = "%s/%s" % (args.topic, args.address)
Expand Down
6 changes: 4 additions & 2 deletions insteon_mqtt/db/Device.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,8 @@ def diff(self, rhs):

delta = DbDiff(self.addr)
for entry in self.entries.values():
rhsEntry = rhs.find(entry.addr, entry.group, entry.is_controller)
rhsEntry = rhs.find(entry.addr, entry.group, entry.is_controller,
entry.data[2])

# RHS is missing this entry or has different data bytes we need
# to update.
Expand Down Expand Up @@ -782,7 +783,8 @@ def _add_using_new(self, addr, group, is_controller, data,
"""
# pylint: disable=too-many-locals

seq = CommandSeq(self.device, "Device database update complete", on_done)
seq = CommandSeq(self.device, "Device database update complete",
on_done)

last_mem_loc = self.last.mem_loc

Expand Down
2 changes: 1 addition & 1 deletion insteon_mqtt/db/DeviceModifyManagerI1.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def handle_lsb_write_response(self, msg, on_done):
"""
# Increment the delta 1
self.db.set_delta(self.db.delta + 1)
self.handle_lsb_response(self, msg, on_done)
self.handle_lsb_response(msg, on_done)

#-------------------------------------------------------------------
def write_lsb_byte(self, on_done):
Expand Down
3 changes: 2 additions & 1 deletion insteon_mqtt/db/ModemEntry.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ def __lt__(self, rhs):
#-----------------------------------------------------------------------
def __str__(self):
return ("ID: %-25s grp: %3s type: %s data: %#04x %#04x %#04x" %
(self.label[:25], self.group, util.ctrl_str(self.is_controller),
(self.label[:25], self.group,
util.ctrl_str(self.is_controller),
self.data[0], self.data[1], self.data[2]))

#-----------------------------------------------------------------------
10 changes: 3 additions & 7 deletions insteon_mqtt/device/Base.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def join(self, on_done=None):
LOG.info("Join Device %s", self.addr)

# Using a sequence so we can pass the on_done function through.
seq = CommandSeq(self, "Operation Complete", on_done)
seq = CommandSeq(self, "Device joined.", on_done)

# First get the engine version. This process only works and is
# necessary on I2CS devices.
Expand Down Expand Up @@ -454,7 +454,7 @@ def get_engine(self, on_done=None):

# Send the get_engine_version request.
msg = Msg.OutStandard.direct(self.addr, 0x0D, 0x00)
msg_handler = handler.StandardCmd(msg, self.handle_engine, on_done)
msg_handler = handler.StandardCmdNAK(msg, self.handle_engine, on_done)
self.send(msg, msg_handler)

#-----------------------------------------------------------------------
Expand Down Expand Up @@ -1092,11 +1092,7 @@ def handle_linking(self, msg, on_done=None):
completed. Signature is: on_done(success, msg, data)
"""
on_done = util.make_callback(on_done)

if msg.flags.type == Msg.Flags.Type.DIRECT_ACK:
on_done(True, "Entered linking mode", None)
else:
on_done(False, "Linking mode failed", None)
on_done(True, "Entered linking mode", None)

#-----------------------------------------------------------------------
def _db_update(self, local_group, is_controller, remote_addr, remote_group,
Expand Down
Loading

0 comments on commit 511a6d7

Please sign in to comment.