Skip to content

Commit

Permalink
Add Documentation for Get_Engine_All; Expand Battery Devices
Browse files Browse the repository at this point in the history
  • Loading branch information
krkeegan committed Feb 1, 2020
1 parent e498dbf commit ce05bef
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 4 deletions.
32 changes: 32 additions & 0 deletions docs/mqtt.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,38 @@ features are available on the device:
```


### Get device engine information

Supported: device

The engine version can be i1, i2, or i2cs. The engine version defines what
type of messages can be used with a device and the type of all link database
used by a device.

New Insteon devices purchased after 2018 are almost certainly all i2cs devices.
By default, we assume a device is i2cs.

If you have an older device that is not responding the the refresh command try
running get_engine and then try running refresh again. This only needs to be
run once on any device. The resulting information will be saved in the device
data.

```
{ "cmd" : "get_engine" }
```

### Get all device engines

Supported: modem

This will cause a get_engine command to be sent to each device (i.e. devices
defined in the config file). If the battery flag is false or not present,
battery operated devices will be skipped. The command payload is:

```
{ "cmd" : "get_engine", ["battery": true/false]}
```

### Add the device as a controller of another device.

Supported: modem, devices
Expand Down
9 changes: 6 additions & 3 deletions insteon_mqtt/Modem.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ def refresh_all(self, battery=False, force=False, on_done=None):
seq.run()

#-----------------------------------------------------------------------
def get_engine_all(self, skip_battery=True, on_done=None):
def get_engine_all(self, battery=False, on_done=None):
"""Run Get Engine on all the devices, except Modem
Devices are assumed to be i2cs, which all new devices are. If you
Expand All @@ -341,7 +341,8 @@ def get_engine_all(self, skip_battery=True, on_done=None):
this.
Args:
skip_battery (bool): If True, skips a battery device.
battery (bool): If True, will run on battery devices as well,
defaults to skipping them.
on_done: Finished callback. This is called when the command has
completed. Signature is: on_done(success, msg, data)
"""
Expand All @@ -352,7 +353,9 @@ def get_engine_all(self, skip_battery=True, on_done=None):

# Reload all the device databases.
for device in self.devices.values():
if skip_battery and isinstance(device, BatterySensor):
if not battery and isinstance(device, (DevClass.BatterySensor,
DevClass.Leak,
DevClass.Remote)):
LOG.ui("Get engine all, skipping battery device %s",
device.label)
continue
Expand Down
11 changes: 11 additions & 0 deletions insteon_mqtt/cmd_line/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,17 @@ def parse_args(args):
help="Don't print any command results to the screen.")
sp.set_defaults(func=modem.refresh_all)

#---------------------------------------
# modem.get_engine_all command
sp = sub.add_parser("get-engine-all", help="Call get-engine on the devices "
"in the configuration.")
sp.add_argument("--battery", action="store_true",
help="Run get-engine on battery devices too, by default "
"they are skipped.")
sp.add_argument("-q", "--quiet", action="store_true",
help="Don't print any command results to the screen.")
sp.set_defaults(func=modem.get_engine_all)

#---------------------------------------
# modem.factory_reset command
sp = sub.add_parser("factory-reset", help="Perform a remote factory "
Expand Down
12 changes: 12 additions & 0 deletions insteon_mqtt/cmd_line/modem.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ def refresh_all(args, config):
return reply["status"]


#===========================================================================
def get_engine_all(args, config):
topic = "%s/modem" % (args.topic)
payload = {
"cmd" : "get_engine_all",
"battery" : args.battery,
}

reply = util.send(config, topic, payload, args.quiet)
return reply["status"]


#===========================================================================
def factory_reset(args, config):
topic = "%s/modem" % (args.topic)
Expand Down
2 changes: 1 addition & 1 deletion insteon_mqtt/device/Base.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ def get_model(self, on_done=None):
on_done: Finished callback. This is called when the command has
completed. Signature is: on_done(success, msg, data)
"""
LOG.info("Device %s cmd: get engine version", self.label)
LOG.info("Device %s cmd: get model", self.label)

# Send the get_engine_version request.
msg = Msg.OutStandard.direct(self.addr, 0x10, 0x00)
Expand Down

0 comments on commit ce05bef

Please sign in to comment.