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

New nodes added in the ISY require restart of module. #69

Open
shbatm opened this issue Mar 3, 2020 · 1 comment
Open

New nodes added in the ISY require restart of module. #69

shbatm opened this issue Mar 3, 2020 · 1 comment

Comments

@shbatm
Copy link
Collaborator

shbatm commented Mar 3, 2020

Right now an error is logged and message ignored if a new node is added to the ISY after the initial connection is made to the event stream.

This module should support live adding/removing of nodes from the ISY (especially with the move to ISYv5).

It shouldn't be too hard to implement, but would probably be best after moving to asyncio (or similar for true async comms -- see #53). I'm thinking if you get a _controlmsg for a node you don't know about, try calling rest/nodes/--unknown node-- and see if you get a good response. If so, add the node an process.

Originally posted by @shbatm in #65

shbatm referenced this issue in shbatm/PyISY Mar 3, 2020
Added #69 for future implementation of live add/remove support.
OverloadUT pushed a commit that referenced this issue Mar 4, 2020
* Black Formatting and Import Sorting.

* Reduce logging level to debug for several calls.

* Fix for shbatm/hacs-isy994#5

* Fix for hint=None causing false error messages on thermostat calls.

* Fixes shbatm/PyISY#16 - Ignore Events for Unknown Nodes

* Add log message on message from unknown node.

Added #69 for future implementation of live add/remove support.

* Fix typo.
OverloadUT added a commit that referenced this issue May 2, 2020
* PyISY V2 Changes (Major Refactoring, Code Cleanup, Thermostat Fixes, Z-Wave Support, Retry Fixes)  (#62)

* Correct malformed Climate commands


Bump Version to 1.1.2


Additional fixes to Climate Functions


Expand Event Results to include value, precision, and UOM

Expanded the Event Results to include more than just the control command.

For climate nodes, not all properties are stored in the actual node definition returned by the ISY. CLIHCS, CLIFS, UOM for example, are only seen as events, and the values are required to do anything useful with them.

A Class has been implemented to capture the other information, but still report back only a string so this is not a breaking change.

* Fix reversed fan modes.

Undid changes to Fan Modes, ISY UOM Documentation incorrect.

* Support retrying ISY commands if they fail

* Fixed indentation

* Use session

* Add public functions to set modes for climate/fan by arguement

Eliminates need to call a private function to be able to pass the climate/fan mode by argument.

* Reduce logging levels to DEBUG for normal traffic messages

Reduced logging level to DEBUG from INFO in several locations to reduce the log flood that occurs (multiple messages logged at INFO level for all ISY actions/events).

* Forked to PyISY_beta for Testing

* Fix Node.aux_properties inconsistent typing

aux_properties is supposed to be a Dict. However, a couple places in the code would initialize a Node by passing in a List.

I fixed this by moving some duplicate List->Dict code in to a method that is called whenever the aux_properties need to be updated, which is also used on Node __init__.

* Bump Version and Description


Correct URL


Fix Typo

* Update to 1.1.5 - Fix PyPi Setup File

* Store Z-wave Device Categories for Nodes

* Bump version to 1.1.6

* Fix missing .firstChild statement.

* Move Node Commands to Node Class, Start Linting and Formatting Cleanup

* Different fix for #43, should also help with #22

* Major Code Refactoring and Cleanup. (#4)

- Massive code cleanup and standardization.
- Reorganized to reduce redundant functions and code.
- Updated to Python 3 PEP8 standards in most places (except where it would break compatibility).
- Added dynamically added functions for nodes and programs to reduce redundant code and allow for future customization based on node type
- Added `formatted` values to Nodes where available.
- Updated dimmable to be valuable with ISYv5 UOMs (was always false)
- BREAKING CHANGE: `lock` and `unlock` functions are now `secure_lock` and `secure_unlock`.

* Move most request functions to their relevant class definition.

* Updates to NodeBase type errors.

* New command cleanup.

* Revert -beta Branch and forecast version to 1.2.0

* Remove errant WARNING log entry.

* Fix bad hint updates for non-ON/OFF commands.

* Cleanup Variables functions and names, minimize calls to ISY.


Remove debugging log calls.

* Don't double-dip on initial Node Status updates.

* Raise error for None passed as value for variables.

* Respect auto_update for Programs and update version to 1.1.11

* Correct logging for Loading Nodes/Groups/Folders

* Fix uninitalized state variable

* Fix repeated program calls on Node Server node updates.

* Read socket 4kb at a time instead of using readline()

* Remove unneaded self._reader()

* Fix socket buffer size check

* Use len instead of getsizeof on Socket data size

* Resolve comments from initial review.

* Fix str/int cast error in groups.

* Move node event handlers to separate file to prevent import errors.

* Actually fix casting errors in Group.py

* Fix missing named parameter.

* nodeDefId is an attribute, not a child.

* Fix bug where Climate _parse_val_dir doesn't return a tuple.

* Call correct parse_notes function (Fixes shbatm/PyISY#11)

* Parse node.enabled as boolean not string (Fix shbatm/PyISY#12)

* Fix shbatm#14 - improper error handling in Nodes __getitem__ call.

* Add changelog, cleanup setup.py, Updates from review.


Cleanup versioning

Co-authored-by: rccoleman <[email protected]>
Co-authored-by: Greg Laabs <[email protected]>

* [v2] Black Formatting and Import Sorting. (#63)

* Black Formatting and Import Sorting.

* Reduce logging level to debug for several calls.

* Allow updating precision and UOM if they change (Addresses shbatm#13) (#67)

* Add ISY Clock and Location Support (#68)

Merge Cleanup for Clock Changes, Fix Program Times


Add ISY Clock and Location Support
v2 Clock

* [V2] Various Bug Fixes (#65)

* Black Formatting and Import Sorting.

* Reduce logging level to debug for several calls.

* Fix for shbatm/hacs-isy994#5

* Fix for hint=None causing false error messages on thermostat calls.

* Fixes shbatm/PyISY#16 - Ignore Events for Unknown Nodes

* Add log message on message from unknown node.

Added #69 for future implementation of live add/remove support.

* Fix typo.

* [V2] Add Z-Wave T-Stat UOM, Light Query Parameters, Fade Up/Down/Stop Support (#70)

* Add Fade Up/Down/Stop Command Support and UOM for Z-Wave TStat Commands

Add support for Fade Up, Fade Down, and Fade Stop commands.

Fix a bug in Z-Wave Thermostat control commands where it expects the UOM to be sent back (otherwise it assumes deg C).
Fix missing 'self.' on function call from #7 fix

* Allow Query Params for RGB Lights per shbatm/PyISY#17

* Modify Group Status Method to show an all_on property (#72)

The Group (scene) status method has been updated to use list comprehension to determine the group state. It will now also return an aux_property for "all_on" -- true if all devices in the scene are on, false if only some of the devices are on.
Flip order for group off update for smooth transition.

* Expose Firmware, UUID, and Hostname properties (#73)

Expose the hostname as `isy.hostname`.

Expose the UUID and Firmware from the Configuration:
- isy.configuration.firmware
- isy.configuration.uuid
Update CHANGELOG


Update UUID function.

* Rename message functions to be more descriptive. (#75)

Rename _upmsg, _routemsg, _controlmsg to more descriptive names.

* [V2] Add Protocol Property (#74)

* Add Protocol Property.

Added a protocol property to each node, group, program, and variable to determine the root protocol used:
- Insteon
- Z-Wave
- Zigbee
- Node Server (w/ Slot #)
- Program
- Program Folder
- State/Integer Variable

* Add stored Family Property. More string literals and constants. 

Save the Family property and translate the ID given into the friendly name as per the UDI WSDK.

Clean up `ATTR_` string literals to represent what they actually are (XML attributes or XML tags).

Add more string literals wherever possible.
Hide Pylintrc File

* [V2] Pick up extra aux_properties from event stream (moved from HASS). (#71)

* Pick up extra aux_properties from event stream (moved from HASS).

Add 'formatted' value to aux properties
Use the `on level` (OL) as the hint if ON was called with no brightness. So if you have an on level of 60% and just call ON() with no brightness it will use a hint of 60%.

* Update aux properties before firing control event.

* Add Insteon Ramp Rate Translation to Constants


Translate Ramp Rates to Seconds

Automatically change the reported value of ramp rate index to a real value in seconds.

* Cleanup Merge Errors from PRs

Cleanup of merging errors and conflicts from PRs:
#70, #72, #73, #74, #75

* Fix additional merging errors.

* [V2] Code Conformance Cleanup (BREAKING CHANGES) (#76)

* Linting Cleanup and snake_case Naming Cleanup
Rename message functions to be more descriptive.

Rename _upmsg, _routemsg, _controlmsg to more descriptive names.
Fix Error Types for XML Parsing


Add missing IndexError

* Rename nid, pid to address for consistency. Rename on/off to turn_on/off

* Linting mopup, Add isy.connected property


Fix Line Endings.

* Rename folders to lowercase for conformance.

* Fix new capitalizations

Remaining PyLint Report:

```
************* Module PyISY.climate
PyISY/climate.py:246:8: W0702: No exception type(s) specified (bare-except)
PyISY/climate.py:259:16: W0702: No exception type(s) specified (bare-except)
PyISY/climate.py:299:4: C0116: Missing function or method docstring (missing-function-docstring)
************* Module PyISY.connection
PyISY/connection.py:17:0: E0401: Unable to import 'requests.packages.urllib3.poolmanager' (import-error)
PyISY/connection.py:61:16: E1101: Module 'requests.packages' has no 'urllib3' member (no-member)
PyISY/connection.py:91:38: W1505: Using deprecated method encodestring() (deprecated-method)
************* Module PyISY
PyISY/__init__.py:1:0: C0103: Module name "PyISY" doesn't conform to snake_case naming style (invalid-name)
PyISY/__init__.py:30:7: W0703: Catching too general exception Exception (broad-except)
************* Module PyISY.nodes.node
PyISY/nodes/node.py:223:-1: W0105: String statement has no effect (pointless-string-statement)
************* Module PyISY.nodes.nodebase
PyISY/nodes/nodebase.py:138:15: W0212: Access to a protected member _val of a client class (protected-access)
************* Module PyISY.programs.__init__
PyISY/programs/__init__.py:244:2: W0511: TODO: Unpack into proper properties. (fixme)
```

* Fix missing Error Type

* Add pylintrc file

* Corrections to capitalization and update CHANGELOG

* Minor pylint corrections.

* Revert previous V2 change to dynamically add node commands (#78)

Also exposes is_thermostat and is_lock property in Node class.
Merge Errors

* [V2] Use structured dict-based class for Aux_Properties (#77)

* Correct UOM for Ramp Rate in Aux Properties

* Get formatted value from correct location in event stream XML

Formatted value is passed as a `fmtAct` tag in the event stream, not as an attribute for the value like if calling `/rest/nodes/ADDRESS`

* Use structured dict-based class for Aux_Properties

Include migration of a few more constants used in other integrations to string literals.

Move and rename EventResult class to NodeProperty class. Moved to helpers to prevent circular imports.
Cleanup

Use NodeProperty for Aux_Props

* Correct extra quotes in strings. Use new NodeProperty formatting.

* Correct logic for adding ramp rates to aux_properties from nodes.xml

Else/Elif Logic was malformed in the ramp rate check when processing nodes.xml. Ramp rate would be translated, but never added to aux_props.

Logic was correct when picking up the ramp rate in the event stream.

* iSort and Black Formatting

* Corrections to dict inherited class.

* Simplify Logging Call

* Proper handling of Parent and Primary Node properties (#80)

Setup for Device Grouping in Home Assistant as well as future solution to automacus/PyISY#11

* Expose additional config options as properties. Add XML helper function (#79)

Expose the ISY Model as a property and expose if variables and nodedefs are enabled in the ISY.
Extract ISY Name as Config Property


Fix extra attribute

* [V2] Add Pre-Commit Config for Black, iSort, Flake8, and Codespell (#81)

* Add Pre-Commit Config for Black, iSort, Flake8, and Codespell

This adds `pre-commit` tests and repos for `black`, `isort`, `flake8`, and `codespell`.

To use:
```shell
pip install pre-commit
pre-commit install

pre-commit run --all-files
```

* Bump minimum Python Version for HTTPS to 3.7

Fix pylint errors for urllib3

* Expose a host of Z-Wave Properties (#84)

Return the manufacturer string for Z-Wave Devices
Include references for Node Categories and Z-Wave Dev Type Categories
Add color bulbs to "dimmable" property.
Add missing units of measure and control names for ISYv5
Fix ZWaveProperties to properly inherit from dict

Update ZWaveProperties class to correctly inherit from Dict.
Simplify Logging Call

* [V2] Allow initializing Connection without initializing full ISY Class (#85)

* Allow initializing Connection without initializing full ISY Class

Make adjustments to the Connection class to allow testing a connection or making calls to the ISY to request resources without the need to initialize a full ISY class.

Initializing the base ISY class makes 9 requests to different ISY REST endpoints to fully initialize a local structure. Sometimes, you only want to test the connection, or call a single endpoint.

With these changes you can do the following to simply test the connection, before initializing the full module, or use that connection to call a single endpoint.

```python
from pyisy import Connection

try:
  isy_conn = Connection(--same params as ISY class--)
except ValueError:
  print("Could not connect to ISY")
```
Update Changelog
Update Configuration to allow calls without an initialized ISY object.

* Add ability to set webroot for ISY Portal Connections (Fixes #82)

Adds the ability to set the webroot (trailing URL path) in order to properly connect to ISYs hosted through the ISY Portal.  See CHANGELOG for connection details.

Ref: #82
Fix SOAP String Formatting for Portal Connections

* Add example connection script.
Add test connection to example

* Move to examples folder.

* Add misc commands for Nodes and Groups (#87)

- Add Ramp Rate and On Level Commands
- Add enable/disable for Nodes and Groups
- Better naming for Fan Mode Command
  - Reverts to match previous function naming from dynamic names.

* Finally fix #11 (#86)

Manually check if single nodes are a parent for other nodes.

This was not possible using the existing code because the way the root assignment and get_by_id of the Nodes class is set up, you can never return a Nodes class (group of nodes) for a single Node ID, regardless of if it has children or not.  So all_lower_nodes, children, and has_children always returned empty for a node.

Also updated the REPR function to print Group Members.

* [V2] Retire Climate Module, Re-enable Networking, Parity with PyISY-Beta (#88)

* Remove support for Climate and Re-enable Networking modules

- Removes support for the retired Climate Module
- Re-enables the Networking Module to allow calls to network resources on the ISY.
- General clean-up and consolidation

* Better handling of error when user does not have variables defined

* [V2] Remove VarEvents, Unpack Program Props, F-Strings, Function Sorting (#89)

* Remove VarEvents, Unpack Program Props, F-Strings, Function Sorting

Another mop-up PR to clean-up everything for V2.

- Remove the external dependency on VarEvents in favor of using property setters and the existing EventEmitter class.
- Unpack Program Properties into actual Properties.
- Update to f-strings where possible
- Sort some class properties and methods by something reasonable:
  - `init` first
  - special methods (`__method__`)
  - properties, alphabetical
  - class methods, some practical order
  - function calls to the ISY, alphabetical.

* Program bug fixes.

* Verbose Logging, Variable Errors, Encoding

1) Move the Event Stream raw XML logging to VERBOSE (5) Logging Level.
2) Add other options for undefined variables
3) Let Minidom handle the encoding instead of manually removing unicode strings from the XML response.

* Update logging level for root group.

* Add Fan Running State to Constants (Fixes shbatm#19)

* Fix shbatm#21: Local variable define in if statement.

* Create an event reader for the isy event stream (#20)

* Create an event reader for the isy event stream

* Add a guard to prevent the loop from collapsing if there is a downstream exception

* Black, iSort, Flake8 updates from pre-commit.

* Minor changes to naming and constants.

* Drop Python 2 Support in Buffer Data

Co-authored-by: shbatm <[email protected]>

* Add some additional properties from /notes

Co-authored-by: J. Nick Koston <[email protected]>

* [V2] Improved Consistency in Error Handling, Fix Type Inconsistency (#91)

* Fix type inconsistency with state values.

* Raise inherited exceptions instead of throwing new exception

* Consistent error types for XML parsing.

Also includes ExpatError for malformed XML

* [V2] Use Instance instead of Class Variables To Support Multiple ISYs (#92)

Eliminate the use of Class variables in favor of Instance Variables. Using Class Variables for the navigator classes causes an issue when multiple ISYs are in use.  Only one instance of PyISY is loaded, so it attempt to share the same lists for all instances of the ISY class. When multiple ISYs are connected in the same program, this causes errors.

* Fix condition in set_on_level and set_ramp_rate (#93)

* [V2] Missing constant, query command, get_by_name fix, and Update README (#94)

* [V2] Use Instance instead of Class Variables To Support Multiple ISYs

Eliminate the use of Class variables in favor of Instance Variables. Using Class Variables for the navigator classes causes an issue when multiple ISYs are in use.  Only one instance of PyISY is loaded, so it attempt to share the same lists for all instances of the ISY class. When multiple ISYs are connected in the same program, this causes errors.

* Add missing constant. Update README.

* Expose the ISY Query Function for All Nodes and Specific Addresses

Adds the isy.query() function to run a full or device-specific query.

* [V2] Fix get_by_name functions in nodes, programs, and add to variables

* Actually fix #50 - Don't update all vars if using auto.

* Rename parameter

Co-authored-by: shbatm <[email protected]>
Co-authored-by: rccoleman <[email protected]>
Co-authored-by: J. Nick Koston <[email protected]>
@shbatm
Copy link
Collaborator Author

shbatm commented May 3, 2020

Just a note: I'll leave this open for now since it'd still be nice to support natively, but at least on the Home Assistant side: https://github.com/shbatm/hacs-isy994/releases/tag/v1.4.1 adds a reload service which can be called to refresh the whole module and pickup new nodes without a full restart.

@shbatm shbatm changed the title [V2] New nodes added in the ISY require restart of module. New nodes added in the ISY require restart of module. Sep 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant