Skip to content

Add support for switchbot presence sensor#156314

Merged
joostlek merged 4 commits into
home-assistant:devfrom
lukasmalkmus:add-switchbot-presence-sensor
Nov 25, 2025
Merged

Add support for switchbot presence sensor#156314
joostlek merged 4 commits into
home-assistant:devfrom
lukasmalkmus:add-switchbot-presence-sensor

Conversation

@lukasmalkmus
Copy link
Copy Markdown
Contributor

@lukasmalkmus lukasmalkmus commented Nov 10, 2025

👋 First-time contributor

First contribution to Home Assistant. Created with AI assistance, thoroughly reviewed and tested with actual hardware on HA 2025.11.1. All entities working correctly.

Compact implementation (~93 lines, mostly tests) following recent merged PRs (#155124, #155309). Happy to receive feedback and make adjustments!

Proposed change

Add SwitchBot Presence Sensor support to the switchbot Bluetooth integration.

The device combines mmWave radar, PIR sensor, and light detection. Already supported by PySwitchbot 0.73.0 (PR #410) and the switchbot_cloud integration (#155309), but missing from the Bluetooth integration.

Changes: Add device type to supported models list and configure platforms (binary_sensor + sensor). Pattern matches Motion Sensor.

Entities: Motion + Light (binary_sensor), Battery + Light level + Signal strength (sensor)

Screenshots

Screenshot 2025-11-10 at 23 47 59

Type of change

  • New feature (adds functionality to existing integration)

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass (will pass in GitHub CI - macOS has Bluetooth dependency issues)
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Ruff
  • Tests have been added to verify that the new code works.

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
  • Updated derived files by running python3 -m script.hassfest (will run if requested)
  • No new dependencies added (uses existing PySwitchbot 0.73.0)

Testing

Tested on HA 2025.11.1 with real hardware. Device discovered automatically via Bluetooth, all 5 entities created and reporting correctly.

Test added following climate panel pattern (#155124), verifying entity counts and attributes.

Copy link
Copy Markdown
Contributor

@home-assistant home-assistant Bot left a comment

Choose a reason for hiding this comment

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

Hi @lukasmalkmus

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@home-assistant
Copy link
Copy Markdown
Contributor

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@home-assistant
Copy link
Copy Markdown
Contributor

Hey there @Danielhiversen, @RenierM26, @murtas, @Eloston, @dsypniewski, @zerzhang, mind taking a look at this pull request as it has been labeled with an integration (switchbot) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of switchbot can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign switchbot Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.

@italo-lombardi
Copy link
Copy Markdown
Contributor

italo-lombardi commented Nov 11, 2025

Hi @lukasmalkmus, thanks for this PR!

JFYI, the Switchbot Smart Radiator Thermostat support by @zerzhang has just been merged: #155123
It changes the same files as yours, so you may need to rebase, and it can also be useful to validate your code.

Thanks again

Copy link
Copy Markdown
Member

@joostlek joostlek left a comment

Choose a reason for hiding this comment

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

There's a merge conflict

@home-assistant home-assistant Bot marked this pull request as draft November 11, 2025 12:55
@borgqueenx
Copy link
Copy Markdown

This shows "motion" in your screenshot. As its a presence sensor, it would likely be better to show "occupancy" instead, with also the house icon instead of motion icon.

@lukasmalkmus lukasmalkmus force-pushed the add-switchbot-presence-sensor branch from dc8495d to 8561814 Compare November 11, 2025 22:59
@lukasmalkmus
Copy link
Copy Markdown
Contributor Author

Screenshot 2025-11-11 at 23 57 20

Comment on lines +103 to +108
# Presence sensors should use occupancy device class instead of motion
if (
binary_sensor == "motion_detected"
and coordinator.model == SwitchbotModel.PRESENCE_SENSOR
):
self._attr_device_class = BinarySensorDeviceClass.OCCUPANCY
Copy link
Copy Markdown
Contributor Author

@lukasmalkmus lukasmalkmus Nov 11, 2025

Choose a reason for hiding this comment

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

Not sure about this bit but I didn't want to interfere with existing sensors by changing this, globally.

Copy link
Copy Markdown

@borgqueenx borgqueenx Nov 12, 2025

Choose a reason for hiding this comment

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

I would say the light sensor can be called that as well. Unfortunately no lux values so not a lux sensor, but still a light level sensor. Just trying to help out with correct labeling, hope it can be merged soon, bought 7 of these in the hope they were supported, but they were not (yet). Haha.

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.

From what I understand, this might not just be the labeling, which is why I was careful.

And yes, same mistake. Bought a bunch just to find out they are not (yet) compatible, lol 🤦

@lukasmalkmus lukasmalkmus marked this pull request as ready for review November 11, 2025 23:01
@borgqueenx

This comment was marked as off-topic.

@lukasmalkmus lukasmalkmus force-pushed the add-switchbot-presence-sensor branch from 8561814 to dfada38 Compare November 14, 2025 15:20
@iz8mbw

This comment was marked as off-topic.

frenck
frenck previously requested changes Nov 23, 2025
Copy link
Copy Markdown
Member

@frenck frenck left a comment

Choose a reason for hiding this comment

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

Oh hi there @lukasmalkmus 👋

Thanks for the pull request. However, the tests seems to be failing right now. Can you take a look and make sure they pass?

Thanks already! 🙏

../Frenck

                       

Blogging my personal ramblings at frenck.dev

@home-assistant home-assistant Bot marked this pull request as draft November 23, 2025 15:19
@italo-lombardi

This comment was marked as off-topic.

@lukasmalkmus lukasmalkmus force-pushed the add-switchbot-presence-sensor branch 2 times, most recently from ed89d72 to 2057d8a Compare November 24, 2025 16:02
@lukasmalkmus lukasmalkmus force-pushed the add-switchbot-presence-sensor branch from 2057d8a to 2f52f3b Compare November 24, 2025 16:06
@lukasmalkmus
Copy link
Copy Markdown
Contributor Author

lukasmalkmus commented Nov 24, 2025

Oh hi there @lukasmalkmus 👋

Thanks for the pull request. However, the tests seems to be failing right now. Can you take a look and make sure they pass?

Thanks already! 🙏

../Frenck

                       

Blogging my personal ramblings at frenck.dev

Hi,

I rebased on latest main, every check seems to pass, now (apart from the ones I can't trigger as I miss workflow approval).

EDIT:

I think most of the comments here are a result of frustration about the poor marketing from SwitchBot. I bought the sensor because the product page explicitly stated that it supports Home Assistant without a Hub.

SwitchBot Bluetooth being a gold rated HA integration, I thought I'm just doing something wrong and reached out to SwitchBot support. After going through the usual first-level support shenanigans of providing screenshots, diagnostics, etc. it turns out the support is just not there and scheduled to be available Nov. 31st. A little more detail in the marketing material would have helped many of us :)

@lukasmalkmus lukasmalkmus requested a review from frenck November 24, 2025 16:11
@lukasmalkmus lukasmalkmus marked this pull request as ready for review November 24, 2025 16:43
@iz8mbw
Copy link
Copy Markdown

iz8mbw commented Nov 25, 2025

So we now we have this PR and this other one for the same goal and both not yet merged.
Hope in a conclusion of this story, my SwitchBot Presence Sensor is waiting for a "real life" with HA :-)

@lukasmalkmus lukasmalkmus force-pushed the add-switchbot-presence-sensor branch from 75eeea9 to d461cc6 Compare November 25, 2025 13:54
@joostlek
Copy link
Copy Markdown
Member

Can you please stop force pushing? I pushed changed to get it mergable and now it's overwritten again...

@lukasmalkmus
Copy link
Copy Markdown
Contributor Author

lukasmalkmus commented Nov 25, 2025

So we now we have this PR and this other one for the same goal and both not yet merged. Hope in a conclusion of this story, my SwitchBot Presence Sensor is waiting for a "real life" with HA :-)

I'm not emotionally attached to this piece of code so I happily accept the other PR being merged (not that I have any authority over that 😄) since the author seems to be affiliated with SwitchBot.

(I still incorporated the missing battery_range sensor from #157148 for completeness).

And finally the tests pass, forgot to update them.

@joostlek
Copy link
Copy Markdown
Member

I am going to check with Switchbot on the battery range, as I think it's weird to both have battery state and battery range. It doesn't add much IMO (why add a vague option when you have a precise one available)

@joostlek joostlek force-pushed the add-switchbot-presence-sensor branch from b96dfbb to b83720e Compare November 25, 2025 14:09
@joostlek joostlek merged commit a0323e8 into home-assistant:dev Nov 25, 2025
36 checks passed
@iz8mbw
Copy link
Copy Markdown

iz8mbw commented Nov 25, 2025

Thanks @lukasmalkmus @joostlek

@lukasmalkmus
Copy link
Copy Markdown
Contributor Author

Can you please stop force pushing? I pushed changed to get it mergable and now it's overwritten again...

Ah, my bad! I Didn't see that. I recently adopted Jujutsu and now I developed a habit of force pushing. Forgot for a second I'm not alone on this branch.

@lukasmalkmus lukasmalkmus deleted the add-switchbot-presence-sensor branch November 25, 2025 17:43
@borgqueenx
Copy link
Copy Markdown

Thank you all for the help getting this merged!

@github-actions github-actions Bot locked and limited conversation to collaborators Nov 26, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

switchbot bluetooth reports "no devices found" for switchbot presence sensor

10 participants