Skip to content

Commit

Permalink
Merge pull request #361 from TD22057/dev
Browse files Browse the repository at this point in the history
Version 0.8.0
  • Loading branch information
krkeegan authored Mar 2, 2021
2 parents 4c029d9 + 84dfe61 commit 730d2fe
Show file tree
Hide file tree
Showing 82 changed files with 5,389 additions and 3,908 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.6
current_version = 0.8.0
commit = True
tag = False

Expand Down
35 changes: 35 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,34 @@
# Revision Change History

## [0.8.0]

This update is the culmination of a significant refactor of the underlying
code including PRs #308, #320, #325, #330, and #334 as well as other smaller
PRs. These changes began back in 0.7.6 and should be transparent to the end
user. But they should make the underlying code easier to maintain and simpler
to add new devices and features. This is the reason for the jump to 0.8.0.

### Additions

- Added support for hidden door sensors. (thanks @tommycw1) ([PR 324][P324])

- Adds a version command to the modem command topic `{"cmd":"version"}` and
to the command line `insteon-mqtt config.yaml -v`. Both will return the
version of Insteon-MQTT. ([PR 355][P355])

- Adds get_flags suppport to the modem. Only needed for debugging.
([PR 359][P359])

### Fixes

- Fixed an error where setting the MQTT id would prevent subscribing to
MQTT topics. (thanks @kpfleming)([PR 352][P352])

- Updates hassio config to comply with changes in API keys. ([PR 344][P344])

- Fix small bug in BroadcastCmdResponse handler that likely never affected
anyone. ([PR 354][P354])

## [0.7.6]

A few new features and some significant bug fixes. A significant refactor of
Expand Down Expand Up @@ -590,3 +619,9 @@ will add new features.
[P313]: https://github.com/TD22057/insteon-mqtt/pull/313
[P213]: https://github.com/TD22057/insteon-mqtt/pull/213
[P326]: https://github.com/TD22057/insteon-mqtt/pull/326
[P352]: https://github.com/TD22057/insteon-mqtt/pull/352
[P344]: https://github.com/TD22057/insteon-mqtt/pull/344
[P324]: https://github.com/TD22057/insteon-mqtt/pull/324
[P354]: https://github.com/TD22057/insteon-mqtt/pull/354
[P355]: https://github.com/TD22057/insteon-mqtt/pull/355
[P359]: https://github.com/TD22057/insteon-mqtt/pull/359
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ 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.6 ([History](CHANGELOG.md))
Version: 0.8.0 ([History](CHANGELOG.md))

### Recent Breaking Changes

Expand Down
4 changes: 2 additions & 2 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"name": "Insteon MQTT",
"description": "Creates an MQTT interface to the Insteon protocol.",
"slug": "insteon-mqtt",
"version": "0.7.6",
"version": "0.8.0",
"startup": "services",
"arch": ["amd64","armhf","aarch64","i386"],
"boot": "auto",
"auto_uart": true,
"uart": true,
"map": ["config:rw"],
"options": {},
"schema": {},
Expand Down
32 changes: 31 additions & 1 deletion config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,14 @@ insteon:
- 48.3d.46
- 48.b0.ad: 'dim1'

# Battery powered sensors (door, hidden door, window).
# Battery powered sensors (door, window).
battery_sensor:
- 94.a9.12

# Battery powered hidden door sensors
hidden_door:
- 32.a0.4b: 'back'

# Battery powered motion sensors.
motion:
- 21.d6.d9: 'door'
Expand Down Expand Up @@ -449,6 +453,32 @@ mqtt:
dawn_dusk_topic: 'insteon/{{address}}/dawn'
dawn_dusk_payload: '{{is_dawn_str.upper()}}'

#------------------------------------------------------------------------
# Hidden Door Sensors
#------------------------------------------------------------------------

# Hidden Door Sensors will use the state and low battery configuration
# inputs from battery_sensor and add battery voltage which is configured
# here.
#
# To register the hidden door sensor in Home Assistant use MQTT binary
# sensor with a configuration like:
# binary_sensor:
# - platform: mqtt
# state_topic: 'insteon/aa.bb.cc//battery_voltage'
#TODO device_class: 'light'
hidden_door:
# Output topic and payload. This message is sent
# whenever the device is polled and a new voltage, low battery voltage
# or heart beat interval is obtained from the device.
# Available variables for templating are:
# address = 'aa.bb.cc'
# name = 'device name'
# batt_volt = raw insteon voltage level

battery_voltage_topic: 'insteon/{{address}}/battery_voltage'
battery_voltage_payload: '{"voltage" : {{batt_volt}}}'

#------------------------------------------------------------------------
# Leak sensors
#------------------------------------------------------------------------
Expand Down
148 changes: 147 additions & 1 deletion docs/mqtt.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ be identified by it's address or the string "modem".
- [Battery Sensors](#battery-sensors)
- [Dimmers](#dimmers)
- [FanLinc](#fanlinc)
- [Hidden Door Sensors](#hidden-door-sensors)
- [IOLinc](#iolinc)
- [KeypadLinc](#keypadlinc)
- [Leak Sensors](#leak-sensors)
Expand Down Expand Up @@ -98,6 +99,27 @@ Alternatively you can use the nice names from the config.yaml file too:
insteon/command/NICE NAME
```

### Print the Version of Insteon-MQTT

Supported: modem

If requesting help or submitting a bug, you can use this command to get the
version of Insteon-MQTT that you are running:

The default topic location is:

`insteon/command/modem`

```
{ "cmd" : "version"}
```

This command can also be run from the command line:

```
insteon-mqtt -v
```

### Join a New Device to the Network

Supported: devices
Expand Down Expand Up @@ -431,7 +453,19 @@ commands.

### Get and set operating flags.

Supported: devices
Supported: devices, modem (get_flags only)

To request the current flag settings on a device:

```
insteon-mqtt config.yaml get-flags aa.bb.cc
```

The MQTT format of the command is:

```
{ "cmd" : "get_flags"}
```

This command gets and sets various Insteon device flags. The set of
supported flags depends on the device type. The command line tool accepts an
Expand Down Expand Up @@ -1060,6 +1094,118 @@ A sample motion sensor topic and payload configuration is:

---

## Hidden Door Sensors

Hidden Door sensors do not accept any input commands in their normal "off"
state. If you press and hold the link button for about 3 seconds it will
beep and its small LED will blink. It will be awake for about the next 4
minutes where you can download the db and or configure the units many
options. All configuration option offered by this device are available for
configuration here. The open/closed (one group) and low battery are
inherited from the battery sensor inputs. The hidden door sensor adds
another possible state change the 2 groups configuration where it will report
open as ON on group 0x01 and closed as ON on group 0x02. The raw Insteon
reported battery voltage level is reported over MQTT.

Note: The Insteon Dev notes provide 4 points for correlation of this raw
battery level to actual battery voltages.

61=~1.75V
54=~1.6V
51=~1.5V
40=~1.25V (default low battery mark)

The following variable is available for templating:

'batt_volt' is the raw Insteon voltage level

A sample hidden door sensor topic and payload configuration is:

```
hidden_door:
battery_voltage_topic: 'insteon/{{address}}/battery_voltage'
battery_voltage_payload: '{"voltage" : {{batt_volt}}}'
```

To set configuration option on the device, first press and hold the device link
button until it beeps and the LED starts flashing. Next tell insteon-mqtt the
device is awake with:

```
{ "cmd" : "awake" }
```

This will tell insteon-mqtt to send commands right away rather than queuing
until the deice is awake.

View Current configuration in log:

```
{ "cmd" : "get_flags" }
```

This configuration can be changed with the following command:

```
{ "cmd" : "set_flags", "key" : value }
```

An example to turn on two groups:

```
{ "cmd" : "set_flags", "two_groups" : 1 }'
```

Configuration is available for the following options:

The following key/value pairs are available:

- cleanup_report = 1/0: tell the device whether or not to send cleanup
reports

- led_disable = 1/0: disables small led on back of device to blink on
state change

- link_to_all = 1/0: links to 0xFF group (all available groups)

- two_groups = 1/0: Report open/close on group 1 or report open on group 1
and closed on 2

- prog_lock = 1/0: prevents device from being programmed by local button
presses

- repeat_closed = 1/0: Repeat open command every 5 mins for 50 mins

- repeat_open = 1/0: Repeat open command every 5 mins for 50 mins

- stay_awake = 1/0: keeps device awake - but uses a lot of battery

Beyond these flags there are two additional settings:

- Low Battery threshold. This is the raw Insteon voltage level that where
the device will trigger a group 0x03 low battery warning. Example to set to
64 below:

```
{ "cmd" : "set_low_battery_voltage", "voltage" : 64 }
```

- Heart Beat Interval. The sensor will send a heartbeat to prove that it is
functional at a configurable interval. The more frequent it wakes up to
this group 0x04 message the faster the battery will deplete.
The time between heartbeats sent is 5 minutes x this setting. So setting
this value to 24 would be 24 x 5 mins = 120 mins. this can be set from
0 -> 255. Setting to 0 = 24 hours or 1440 minutes. Example: to set to 10
minutes below:

```
{ "cmd" : "set_heart_beat_interval", "interval" : 2 }
```


---

## Leak Sensors

Leak sensors do not accept any input commands. The leak
Expand Down
39 changes: 29 additions & 10 deletions insteon_mqtt/Modem.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import os
import sys
import functools
import insteon_mqtt
from .Address import Address
from .CommandSeq import CommandSeq
from . import config
Expand Down Expand Up @@ -86,10 +87,12 @@ def __init__(self, protocol, stack, timed_call):
'linking' : self.linking,
'scene' : self.scene,
'factory_reset' : self.factory_reset,
'get_flags' : self.get_flags,
'sync_all' : self.sync_all,
'sync' : self.sync,
'import_scenes': self.import_scenes,
'import_scenes_all': self.import_scenes_all
'import_scenes_all': self.import_scenes_all,
'version': self.version
}

# Add a generic read handler for any broadcast messages initiated by
Expand Down Expand Up @@ -245,6 +248,16 @@ def get_addr(self, on_done=None):
msg_handler = handler.ModemInfo(self, on_done)
self.send(msg, msg_handler)

#-----------------------------------------------------------------------
def version(self, on_done=None):
""" Returns the version of insteon_mqtt
Used by the MQTT command:
Default Topic: 'insteon/command/modem'
Payload: '{"cmd": "version"}'
"""
on_done(True, insteon_mqtt.__version__, None)

#-----------------------------------------------------------------------
def refresh(self, force=False, on_done=None):
"""Load the all link database from the modem.
Expand Down Expand Up @@ -700,6 +713,18 @@ def factory_reset(self, on_done=None):
msg_handler = handler.ModemReset(self, on_done)
self.send(msg, msg_handler)

#-----------------------------------------------------------------------
def get_flags(self, on_done=None):
"""Queries and Prints the Modem Flags to the Log
Args:
on_done: Finished callback. This is called when the command has
completed. Signature is: on_done(success, msg, data)
"""
msg = Msg.OutGetModemFlags()
msg_handler = handler.ModemGetFlags(self, on_done)
self.send(msg, msg_handler)

#-----------------------------------------------------------------------
def send(self, msg, msg_handler, high_priority=False, after=None):
"""Send a message to the modem.
Expand Down Expand Up @@ -1026,15 +1051,9 @@ def link_data_from_pretty(self, is_controller, data):
list[3]: List of Data1-3 values
"""
# For the base devices this does nothing
data_1 = None
if 'data_1' in data:
data_1 = data['data_1']
data_2 = None
if 'data_2' in data:
data_2 = data['data_2']
data_3 = None
if 'data_3' in data:
data_3 = data['data_3']
data_1 = data.get('data_1', None)
data_2 = data.get('data_2', None)
data_3 = data.get('data_3', None)
return [data_1, data_2, data_3]

#-----------------------------------------------------------------------
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.6"
__version__ = "0.8.0"

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

Expand Down
Loading

0 comments on commit 730d2fe

Please sign in to comment.