Skip to content

Remove PTZ buttons for cameras that no longer report PTZ - #8

Merged
JoshADC merged 1 commit into
JoshADC:masterfrom
jpettitt:ptz-button-cleanup
Oct 11, 2026
Merged

JoshADC merged 1 commit into
JoshADC:masterfrom
jpettitt:ptz-button-cleanup

Conversation

@jpettitt

Copy link
Copy Markdown

The problem

Fixed cameras get a full set of PTZ buttons. SecuritySpy reports ptzcapabilities from the camera's driver profile, not a probe, so every Reolink or Dahua profile claims pan/tilt/zoom (61) whether or not the camera can move.

Cause

The integration already creates buttons only for a non-zero capability, and the right fix is at the source: ticking Disable PTZ in the camera's Device settings makes SecuritySpy report 0 (verified on 6.21). But buttons created earlier then linger in the entity registry as unavailable, and nothing removes them.

Fix

The button platform now removes registry entries for buttons an online camera no longer reports, at setup. Offline or vanished cameras keep theirs, so an outage can't delete entities and their customisations. Pure decision helper with tests, a README note on the SecuritySpy setting, and a changelog entry under an unreleased 1.4.3.

Tested on a live SecuritySpy 6.21 with HA 2026.9.0: 42 stale buttons removed across six cameras, the four still reporting PTZ untouched.

🤖 Generated with Claude Code

SecuritySpy reports ptzcapabilities from the driver profile, so fixed cameras
claim PTZ until "Disable PTZ" is ticked in their Device settings. Once it is,
the buttons stopped being created but lingered in the registry as unavailable.
Offline or vanished cameras keep theirs so an outage can't delete them.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@JoshADC
JoshADC merged commit 911c6f7 into JoshADC:master Oct 11, 2026
3 of 4 checks passed
@JoshADC

JoshADC commented Oct 11, 2026

Copy link
Copy Markdown
Owner

Sorry for the slow reply on this one — it sat longer than it should have. Merged, and I like that it only removes buttons for cameras that are online right now. That's the line I care about.

One question before it goes into a release: have you ever seen SecuritySpy briefly report a PTZ capability of 0 for an online camera, for example just after a SecuritySpy restart? Back in April I decided against automatically removing cameras that drop out of SecuritySpy, because a glitch could wipe out people's renamed entities. If PTZ capability only comes from the driver profile, I think we're fine. If it can blip, I'd want a guard before 1.4.3.

I'll tidy the extra changelog blank line myself. And thanks for the heads-up on the Validate topics back on #7. I added them the next day and it's been green since; I just never said so.

@jpettitt

Copy link
Copy Markdown
Author

I have seen it but only for camera where I hadn't gone into the advanced setting and turned off PTZ on my Reolink Duo cameras that don't PTZ. That's what prompted this - auto clean if the user turns off PTZ in SecuritySpy.

@JoshADC

JoshADC commented Oct 15, 2026

Copy link
Copy Markdown
Owner

Thanks — that makes sense, and it matches what I see here: my fixed Hikvision reports full PTZ from its driver profile, while my ONVIF-configured cameras report 0. Shipped in v1.4.3 along with the lint cleanup from #9. Appreciate both, and the steady stream of careful PRs.

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

Successfully merging this pull request may close these issues.

2 participants