GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add event listener to smartcam by sdb9696 · Pull Request #1388 · python-kasa/python-kasa

Conversation

@sdb9696

@sdb9696 sdb9696 commented Dec 18, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

No description provided.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
sdb9696 added 3 commits December 18, 2024 13:39
@sdb9696
Add motion module to smartcam
56261e6
@sdb9696
Add listen module to smartcam
99e8a2f
@sdb9696
Use specific listen port and add cli parameters
6b41170
@sdb9696 sdb9696 changed the title Add motion module and event listener to smarcam Add event listener to smartcam Dec 19, 2024
@sdb9696
Update get_ip function
d201e59
rytilahti
rytilahti reviewed Dec 19, 2024
View reviewed changes
Comment thread kasa/cli/listen.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread kasa/eventtype.py
@@ -0,0 +1,12 @@
"""Module for listen event types."""

@rytilahti rytilahti Dec 19, 2024

Copy link
Copy Markdown
Member

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.

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@sdb9696 sdb9696 Dec 19, 2024

Copy link
Copy Markdown
Contributor Author

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.

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

@rytilahti rytilahti Dec 19, 2024

Copy link
Copy Markdown
Member

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.

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@sdb9696 sdb9696 Dec 19, 2024

Copy link
Copy Markdown
Contributor Author

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.

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread kasa/cli/main.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread kasa/cli/listen.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread kasa/cli/listen.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread kasa/smartcam/modules/listen.py
instance_id: str

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

@rytilahti rytilahti Dec 19, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

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.

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?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@sdb9696 sdb9696 Dec 19, 2024

Copy link
Copy Markdown
Contributor Author

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.

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?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread kasa/smartcam/modules/listen.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread kasa/smartcam/modules/listen.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread kasa/smartcam/modules/listen.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@rytilahti rytilahti added the enhancement New feature or request label Dec 19, 2024
@sdb9696
Filter events on state True and add listening address
f4857ef
@codecov

codecov Bot commented Dec 19, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

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.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

sdb9696 added 2 commits December 19, 2024 16:59
@sdb9696
Update post review
8b4f3ed
@sdb9696
Merge branch 'master' into feat/motion
3eb85b8
@sdb9696 sdb9696 added this to the 0.9.1 milestone Dec 19, 2024
@sdb9696
Merge remote-tracking branch 'upstream/master' into feat/motion
ed98d58
@sdb9696 sdb9696 modified the milestones: 0.9.1, 0.9.2 Dec 23, 2024
@DawidPietrykowski

DawidPietrykowski commented Jan 18, 2025

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sdb9696 sdb9696 removed this from the 0.10.0 milestone Jan 23, 2025
@github-actions

github-actions Bot commented 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!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

github-actions Bot commented 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!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

github-actions Bot commented Oct 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!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added the stale label Oct 24, 2025
@github-actions github-actions Bot closed this Oct 31, 2025
@juherr juherr mentioned this pull request Sep 15, 2026
Add LastAlertDetection module for smartcam devices #1762
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@rytilahti rytilahti rytilahti left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

enhancement New feature or request stale

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@sdb9696 @DawidPietrykowski @rytilahti
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.