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

Remove Battery Devices from *_All Commands #540

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
3 changes: 3 additions & 0 deletions docs/battery_devices.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ Battery devices (e.g. motion sensors, remotes, etc) are normally sleeping and wi

> As noted below, not all devices enter an _awake_ state after sending a message. For some devices, the only option is to manually wake them up.

## `*_all` Commands
None of the `*_all` style commands will work on battery devices, you must individually call the commands you wish to run on each battery device.

## Waking a Battery Device

### Automatically
Expand Down
11 changes: 7 additions & 4 deletions docs/initializing.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ When setting up Insteon-MQTT, adding a new device, or to solve problems, it is n

All of these functions are idempotent, they can be run multiple times without causing any issue.

> __Note__ Battery devices (e.g. motion sensors, remotes, etc) are normally sleeping and will not respond to commands sent to them. If the commands below are sent to a battery device, the command will be queued and will attempt to be run the next time the device is awake. For more details, see [battery devices](battery_devices.md)
> __Note__ Battery devices (e.g. motion sensors, remotes, etc) are normally sleeping and will not respond to commands sent to them. If the commands below are sent to a battery device, the command will be queued and will attempt to be run the next time the device is awake. None of the `*_all` commands will work on battery devices, you must individually call each desired command on battery devices. For more details, see [battery devices](battery_devices.md)

1. __Join__ This is necessary to allow the modem to talk to the device. This needs to be done first on any new device or device that has been factory reset. If you are seeing the error `Senders ID not in responders db. Try running 'join' again.`
- To join a __single device__ run `join`.
Expand All @@ -21,7 +21,8 @@ All of these functions are idempotent, they can be run multiple times without ca
Payload: { "cmd" : "join" }
```

- To join __all__ devices run `join_all`. This may be necesary when first setting up a network.
- To join __all__ non-battery devices run `join_all`. This may be necesary when first setting up a network.
- The `join` must be run individually on each desired battery device.

_Command Line_
```
Expand All @@ -47,7 +48,8 @@ All of these functions are idempotent, they can be run multiple times without ca
Payload: { "cmd" : "pair" }
```

- To pair __all__ devices run `pair_all`. This may be necesary when first setting up a network.
- To pair __all__ non_battery devices run `pair_all`. This may be necessary when first setting up a network.
- The `pair` must be run individually on each desired battery device.

_Command Line_
```
Expand Down Expand Up @@ -79,7 +81,8 @@ All of these functions are idempotent, they can be run multiple times without ca
Payload: { "cmd" : "refresh", ["force" : true/false] }
```

- To refresh __all__ devices run `refresh_all`. This may be necesary when first setting up a network. __This may take a while to complete__
- To refresh __all__ non-battery devices run `refresh_all`. This may be necessary when first setting up a network. __This may take a while to complete__
- This `refresh` must be run individually on each desired battery device.

_Command Line_
```
Expand Down
4 changes: 3 additions & 1 deletion docs/mqtt.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,15 @@ data.

Supported: modem

This will cause a get_engine command to be sent to each device (i.e. devices
This will cause a get_engine command to be sent to each non-battery device (i.e. devices
defined in the config file). The command payload is:

```
{ "cmd" : "get_engine_all"}
```

This command must be run individually on each desired battery device.

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

Supported: modem, devices
Expand Down
8 changes: 6 additions & 2 deletions docs/scenes.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ The `import-scenes` function will attempt to keep the order and all comments in
```

### `import-scenes-all`
The `import-scenes-all` function will perform the `import-scenes` function on all devices in the network. The same caveats about `import-scenes` apply to this function as well.
The `import-scenes-all` function will perform the `import-scenes` function on all non-battery devices in the network. The same caveats about `import-scenes` apply to this function as well.

This command must be run individually on each desired battery device.

> The `import-scenes-all` function can take quite a while to complete particularly if you have a lot of devices and scenes and/or a slow computer. For reference 85 devices on a raspberry pi takes about 20 seconds to complete. This may cause the command line to time out before the command completes. The command should continue to run and complete in the background however, you will not see the results printed to the screen. You can solve this by editing the file (../insteon_mqtt/cmd_line/util.py) and changing the line at the top from `TIME_OUT = 10` to something like `TIME_OUT = 30`.

Expand Down Expand Up @@ -140,7 +142,9 @@ The changes will only be made to the device on which this command is called. So
```

### `sync-all`
The `sync-all` function will perform the `sync` function on all devices in the network. The same caveats about `sync` apply to this function as well.
The `sync-all` function will perform the `sync` function on all non-battery devices in the network. The same caveats about `sync` apply to this function as well.

This command must be run individually on each desired battery device.

_Command Line_
```
Expand Down
37 changes: 31 additions & 6 deletions insteon_mqtt/Modem.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from .const import __version__
from .Address import Address
from .CommandSeq import CommandSeq
from .device.BatterySensor import BatterySensor
from . import config
from . import db
from . import handler
Expand Down Expand Up @@ -436,6 +437,9 @@ def refresh_all(self, force=False, on_done=None):
the database sizes. So it usually should only be called if no other
activity is expected on the network.

Battery devices are not included in this command and this command
must be run individually on each battery device.

Args:
force (bool): Force flag passed to devices. If True, devices
will refresh their Insteon db's even if they think the db
Expand All @@ -453,7 +457,8 @@ def refresh_all(self, force=False, on_done=None):

# Reload all the device databases.
for device in self.devices.values():
seq.add(device.refresh, force)
if (not isinstance(device, BatterySensor)):
seq.add(device.refresh, force)

# Start the command sequence.
seq.run()
Expand All @@ -467,6 +472,9 @@ def get_engine_all(self, on_done=None):
lose your data directory. Otherwise you likely never need to use
this.

Battery devices are not included in this command and this command
must be run individually on each battery device.

Args:
on_done: Finished callback. This is called when the command has
completed. Signature is: on_done(success, msg, data)
Expand All @@ -478,7 +486,8 @@ def get_engine_all(self, on_done=None):

# Reload all the device databases.
krkeegan marked this conversation as resolved.
Show resolved Hide resolved
for device in self.devices.values():
seq.add(device.get_engine)
if (not isinstance(device, BatterySensor)):
seq.add(device.get_engine)

# Start the command sequence.
seq.run()
Expand All @@ -490,6 +499,9 @@ def join_all(self, on_done=None):
This calls join on all the devices. This can take a little time. It
is helpful when first setting up a network or replacing a PLM.

Battery devices are not included in this command and this command
must be run individually on each battery device.

Args:
on_done: Finished callback. This is called when the command has
completed. Signature is: on_done(success, msg, data)
Expand All @@ -501,7 +513,8 @@ def join_all(self, on_done=None):

# Join all the device databases.
for device in self.devices.values():
seq.add(device.join)
if (not isinstance(device, BatterySensor)):
seq.add(device.join)

# Start the command sequence.
seq.run()
Expand All @@ -513,6 +526,9 @@ def pair_all(self, on_done=None):
This calls pair on all the devices. This can take a little time. It
is helpful when first setting up a network or replacing a PLM.

Battery devices are not included in this command and this command
must be run individually on each battery device.

Args:
on_done: Finished callback. This is called when the command has
completed. Signature is: on_done(success, msg, data)
Expand All @@ -524,7 +540,8 @@ def pair_all(self, on_done=None):

# Pair all the device databases.
for device in self.devices.values():
seq.add(device.pair)
if (not isinstance(device, BatterySensor)):
seq.add(device.pair)

# Start the command sequence.
seq.run()
Expand Down Expand Up @@ -874,6 +891,9 @@ def _sync_add(self, entry, dry_run, on_done=None):
def sync_all(self, dry_run=True, refresh=True, on_done=None):
"""Perform the 'sync' command on all devices.

Battery devices are not included in this command and this command
must be run individually on each battery device.

See the 'sync' command for a description.

Args:
Expand All @@ -894,7 +914,8 @@ def sync_all(self, dry_run=True, refresh=True, on_done=None):

# Then each other device.
for device in self.devices.values():
seq.add(device.sync, dry_run=dry_run, refresh=refresh)
if (not isinstance(device, BatterySensor)):
seq.add(device.sync, dry_run=dry_run, refresh=refresh)

# Start the command sequence.
seq.run()
Expand Down Expand Up @@ -958,6 +979,9 @@ def import_scenes(self, dry_run=True, save=True, on_done=None):
def import_scenes_all(self, dry_run=True, on_done=None):
"""Perform the 'import_scenes' command on all devices.

Battery devices are not included in this command and this command
must be run individually on each battery device.

See the 'import_scenes' command for a description.

Args:
Expand All @@ -978,7 +1002,8 @@ def import_scenes_all(self, dry_run=True, on_done=None):

# Then each other device.
for device in self.devices.values():
group.add(device.import_scenes, dry_run=dry_run, save=False)
if (not isinstance(device, BatterySensor)):
group.add(device.import_scenes, dry_run=dry_run, save=False)

# Save everything at the end
if not dry_run:
Expand Down
Loading