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

Distinguish add_node / remove_node mode #6

Open
m0rphi opened this issue Jul 24, 2015 · 2 comments
Open

Distinguish add_node / remove_node mode #6

m0rphi opened this issue Jul 24, 2015 · 2 comments

Comments

@m0rphi
Copy link

m0rphi commented Jul 24, 2015

Hi,

I tried to distinguish if the controller is in add_node mode (also called include mode) or in remove_node mode (exclude mode).
In the debug logs from python-openzwave, it seems to be there is the same callback information for both function,
First picture shows the add_node, second the remove_node function
pyozw_add_device
pyozw_remove_device

Here the relevant part:
add_node
DEBUG Z-Wave ControllerCommand : {'controllerState': 'Starting', 'controllerError': 'None', 'controllerErrorInt': 0, 'notificationType': 'ControllerCommand', 'nodeId': 0, 'controllerStateInt': 1, 'controllerErrorDoc': 'None.', 'homeId': 23197916L, 'controllerStateDoc': 'The command is starting.'}
DEBUG Z-Wave ControllerCommand : {'controllerState': 'Waiting', 'controllerError': 'None', 'controllerErrorInt': 0, 'notificationType': 'ControllerCommand', 'nodeId': 0, 'controllerStateInt': 4, 'controllerErrorDoc': 'None.', 'homeId': 23197916L, 'controllerStateDoc': 'Controller is waiting for a user action.'}

remove_node
DEBUG Z-Wave ControllerCommand : {'controllerState': 'Starting', 'controllerError': 'None', 'controllerErrorInt': 0, 'notificationType': 'ControllerCommand', 'nodeId': 0, 'controllerStateInt': 1, 'controllerErrorDoc': 'None.', 'homeId': 23197916L, 'controllerStateDoc': 'The command is starting.'}
DEBUG Z-Wave ControllerCommand : {'controllerState': 'Waiting', 'controllerError': 'None', 'controllerErrorInt': 0, 'notificationType': 'ControllerCommand', 'nodeId': 0, 'controllerStateInt': 4, 'controllerErrorDoc': 'None.', 'homeId': 23197916L, 'controllerStateDoc': 'Controller is waiting for a user action.'}

When you compare both picture, the callback is the same, so I don´t know in which mode the z-wave chip is.

In openzwave logs, there is some difference between add_node and remove_node function
ozw_add_device
ozw_remove_device

Maybe there is another way to find out in python-openzwave in which mode the chip is, but I didn´t find it yet ;)

my system:
OS: Linux Mint 17 32 Bit 3.13.0-24-generic #47-Ubuntu SMP Fri May 2 23:31:42 UTC 2014 i686 i686 i686 GNU/Linux
python-openzwave commit: b4476e2
Python: Python 2.7.6 (default, Mar 22 2014, 22:59:38) [GCC 4.8.2]
cython -V: Cython version 0.20.1post0
HW: Z-Wave Aeotec Z-Stick S2

@m0rphi m0rphi changed the title Distinguish add_node / remove_node Distinguish add_node / remove_node mode Jul 24, 2015
@bibi21000
Copy link
Member

You're right. There is actually no way to retrieve the command from notification.
Openzwave library seems not returning it in notification (or I've not found a way to get it) :
https://github.com/OpenZWave/open-zwave/blob/a11616144bbac2c890a230e18f24cb12894ce49c/cpp/src/Driver.cpp#L5432
I can only get a controller_state and a controller_error :
https://github.com/OpenZWave/open-zwave/blob/a6703f1b50558bc9ce0d1b96bd7fc36dd42a7cec/cpp/src/Driver.h#L483
But not the command which generate it.

So actually you need to "save" the last sent command in a "flag". For me, it's not a good way to do it, that's why I don't implement it. Keep in mind in that user (in dynamic mode with .so modules) can launch an instance of a python program AND an instance of ozwcp for example.
Maybe there must have some work in c++ library to retrieve the way begin_controller_controller was working.
I don't have the time to look at it further more in the next weeks (will be on holidays at the end of next week).
So if you're interest in you speak about that on openzave c++ group on google ... or simply use a flag.
Hope this helps

@m0rphi
Copy link
Author

m0rphi commented Jul 28, 2015

Thanks bibi,
the knowledge if the command was an include or exclude is somehow important, I think.
Right now I am saving a flag for the include/exclude mode.
I found out that openzwave has an interesting behaviour when execute include (add_node) /exclude command (remove_node) multiple times.
It queues e.g. all include commands and when cancel the commands, it cancel only the last include..

For me it´s more comfortable to execute one include command and throw away all other include commands in that time the chip is in include mode.(same for exclude command) . So I have to cancel only once the same command, otherweise the chip could be stuck in include mode all the time. And this state nobody wants to have ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants