FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Add event listener to smartcam by sdb9696 · Pull Request #1388 · python-kasa/python-kasa · GitHub

Repository navigation

Add event listener to smartcam - #1388

Closed
sdb9696 wants to merge 8 commits into
masterfrom
feat/motion
Closed

sdb9696 wants to merge 8 commits into
masterfrom
feat/motion

Conversation

sdb9696 commented Dec 18, 2024 •
edited
Loading

Copy link
Copy Markdown
Contributor

No description provided.

sdb9696 changed the title Add motion module and event listener to smarcam Add event listener to smartcam Dec 19, 2024
Comment thread kasa/cli/listen.py Outdated
Comment thread kasa/eventtype.py
@@ -0,0 +1,12 @@
"""Module for listen event types."""

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

We probably want to keep this inside smartcam for now, as the types are very onvif-specific(?)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I think it's better to have this at the top level so we can add other listen modules like for trigger logs and motion detection sensors.

Comment thread kasa/cli/main.py
"device": None,
"feature": None,
"light": None,
"listen": None,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

How about a new sub group "camera", which would contain this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

As above I think we should keep this generic so we can add other listen modules like for trigger logs and motion detection sensors and have them all exposed with the one cli command. Users can provide the EventType options if they want to limit the events.

Comment thread kasa/cli/main.py Outdated
Comment thread kasa/cli/listen.py Outdated
Comment thread kasa/cli/listen.py Outdated
instance_id: str

async def _invoke_callback(self, event: EventType) -> None:
self.callback(event)

rytilahti Dec 19, 2024 •
edited
Loading

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Debug log the event here? I had to go and use wireshark to extract the full SOAP payload to see what's happening :-)

Here's one for the reference:

<?xml version="1.0"?>
<SOAP-ENV:Body>
  <wsnt:Notify>
    <wsnt:NotificationMessage>
      <wsnt:SubscriptionReference>
        <wsa5:Address>http://192.168.123.123:2020/event-1_2020</wsa5:Address>
      </wsnt:SubscriptionReference>
      <wsnt:Topic Dialect="http://www.onvif.org/ver10/tev/topicExpression/ConcreteSet">tns1:VideoSource/MotionAlarm</wsnt:Topic>
      <wsnt:ProducerReference>
        <wsa5:Address>http://192.168.123.123:5656/event</wsa5:Address>
      </wsnt:ProducerReference>
      <wsnt:Message>
        <tt:Message PropertyOperation="Changed" UtcTime="2024-12-19T12:53:07Z">
          <tt:Source>
            <tt:SimpleItem Value="raw_vs1" Name="Source"/>
          </tt:Source>
          <tt:Data>
            <tt:SimpleItem Value="false" Name="State"/>
          </tt:Data>
        </tt:Message>
      </wsnt:Message>
    </wsnt:NotificationMessage>
  </wsnt:Notify>
</SOAP-ENV:Body>

See state = false, i.e., detection probably stopped?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Now logging all messages although I'm worried this might be a bit too verbose. Maybe this should be a separate verbose flag to function?

Comment thread kasa/smartcam/modules/listen.py Outdated
Comment thread kasa/smartcam/modules/listen.py Outdated
rytilahti added the enhancement New feature or request label Dec 19, 2024

codecov Bot commented Dec 19, 2024 •
edited
Loading

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 49.35897% with 79 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.60%. Comparing base (63f4f82) to head (ed98d58).
⚠️ Report is 101 commits behind head on master.

Files with missing lines Patch % Lines
kasa/smartcam/modules/onviflisten.py 38.77% 60 Missing ⚠️
kasa/cli/listen.py 45.71% 19 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1388      +/-   ##
==========================================
- Coverage   92.42%   91.60%   -0.83%     
==========================================
  Files         132      135       +3     
  Lines        8203     8354     +151     
  Branches      839      847       +8     
==========================================
+ Hits         7582     7653      +71     
- Misses        459      539      +80     
  Partials      162      162              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

sdb9696 added this to the 0.9.1 milestone Dec 19, 2024
sdb9696 modified the milestones: 0.9.1, 0.9.2 Dec 23, 2024

Copy link
Copy Markdown
Contributor
TOPIC_EVENT_TYPE = {
    "tns1:RuleEngine/CellMotionDetector/Motion": EventType.MOTION_DETECTED,
    "tns1:RuleEngine/CellMotionDetector/People": EventType.PERSON_DETECTED,
    "tns1:RuleEngine/TamperDetector/Tamper": EventType.TAMPER_DETECTED,
}

How did you find those topics? There is also

  • Pet detection
  • Meow detection
  • Bark detection
  • Glass break detection
  • Vehicle detection

I just added pet detection configuration in #1465 and I'll try to add the rest soon. Would be great if these events were also included in this PR. I'm open to helping as I have one C220 available for testing.

Are you reverse engineering through packet sniffing or are those topics listed somewhere in the spec?

I hope this gets merged, tested locally and motion detection works well. Thanks for the effort.

sdb9696 removed this from the 0.10.0 milestone Jan 23, 2025

Copy link
Copy Markdown

There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days.
If you are the author of this PR, please leave a comment if you want to keep it open. Also, please rebase your PR onto the latest dev branch to ensure that it's up to date with the latest changes.
Thank you for your contribution!

github-actions Bot added stale and removed stale labels Apr 24, 2025

Copy link
Copy Markdown

There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days.
If you are the author of this PR, please leave a comment if you want to keep it open. Also, please rebase your PR onto the latest dev branch to ensure that it's up to date with the latest changes.
Thank you for your contribution!

github-actions Bot added stale and removed stale labels Jul 24, 2025

Copy link
Copy Markdown

There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days.
If you are the author of this PR, please leave a comment if you want to keep it open. Also, please rebase your PR onto the latest dev branch to ensure that it's up to date with the latest changes.
Thank you for your contribution!

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL