-
-
Notifications
You must be signed in to change notification settings - Fork 70
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
Generic Presence Detection #234
Conversation
Signed-off-by: Rich Koshak <rlkoshak@gmail.com>
|
||
# Item and sensor are the same, cancel the flapping timer if there is | ||
# one. | ||
global presence_timers # For the love of Pete why?! I get "use before assigned" errors without the global |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because you are assigning the value at line 136. It looks like a mistake, you should be doing presence_timers[proxy_name]
I think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yes that would explain it. You are right, that is totally a bug. Wonder why this worked when I tested it? I bet I only tested it with one Timer running at a time. I'll test it some more this evening and check in the fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, this bug should be fixed in the most recent commit. I was able to test live data with multiple Timers yesterday and it work as expected.
Community/GenericPresence/automation/jsr223/python/community/genericpresence/presence.py
Show resolved
Hide resolved
I was experiencing some strange behavior (i.e. Timers not being cancelled when they are supposed to be) so I simplified some of the code and and added a new Rule to synchronize the proxy Items with the current/restored sensor readings at Rule startup. I also added code where the user can set a name metadata on the proxy Item and get more human friendly logs and/or use it in TTS announcements and the like. |
Rather than configured with a list of items could the script be configured to use a group that is defined? |
It already works that way. The list is expected to be a list of Groups. In my current setup and in the example in the docstrings, there are three Groups. One generic group that represents when someone is home (gPresent), one specific group that represents when Rich is home (gRichPresent) and one group that represents when Jenn (gJennPresent) is home. Each of those Groups have more than one member and the script will track each of them separately. If you only care whether someone is home, you just need the one Group (gPresent). The docs are to show how you can also separately track individual people, not just over all presence. |
Community/GenericPresence/automation/jsr223/python/community/genericpresence/presence.py
Outdated
Show resolved
Hide resolved
Community/GenericPresence/automation/jsr223/python/community/genericpresence/presence.py
Outdated
Show resolved
Hide resolved
Community/GenericPresence/automation/jsr223/python/community/genericpresence/presence.py
Show resolved
Hide resolved
@rkoshak is the most recent version in this PR actually working for you? For me there seems to be anything wrong with the lambda function, which I can't get fixed. I always get the following errors when the rule is triggered:
any ideas? |
I've been running with it since before I posted it here. The lambda itself is as simple as can be. I'm not sure what could be throwing an exception from there. Put everything in away() inside a try/except and log out the contents of the exception.
That should tell us what the error is and on which line it occurs. I can't imagine what it would be though. Perhaps |
This PR is ready for review |
That did not help, but I think I found the problem. After adding |
I'm not certain why that import is missing in the first place, but that would cause problems. EDIT: I also figured out what went wrong. In my environment I have this code in two places (I have a utility function to get_name using get_value). When I copied it over and tested it I didn't run through the get_name code apparently. |
Signed-off-by: Rich Koshak <rlkoshak@gmail.com>
I've basically completely rewritten this so am closing this PR. When reviewing submissions to the helper library becomes a priority I'll resubmit. In the mean time I'll keep in in my own repo where I can continue development. |
Initial implementation of the Generic Presence Detection example from the forum. I've expanded it somewhat so that it can track both overall presence as well as presence of individuals. I use Scott's automatically generated Rule Triggers trick to make that happen. Configuration takes place through three variables in configuration.py, two lists (list of sensor Items and corresponding proxy Items) as well as the flapping time.
As I type this message it occurs to me that I could use a single List of tuples which would let me have a different flapping timeout value for each person. I'll await the initial review though before I add that.