Skip to content
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

Use 'occupancy' device_class instead of 'motion' for occupancy sensors #22896

Merged
merged 1 commit into from
Jun 2, 2024

Conversation

agoode
Copy link
Contributor

@agoode agoode commented Jun 2, 2024

'occupancy' matches the zigbee terminology more closely and is more consistent with other Home Assistant entities of this type.

https://www.home-assistant.io/integrations/binary_sensor/

In general, it looks like 'motion' is more for alarms, and 'occupancy' for non-alarm situations. Z2M currently makes no distinction between these concepts, but they could be separated (with a fair amount of work).

'occupancy' matches the zigbee terminology more closely and is more
consistent with other Home Assistant entities of this type.

https://www.home-assistant.io/integrations/binary_sensor/

In general, it looks like 'motion' is more for alarms, and 'occupancy'
for non-alarm situations. Z2M currently makes no distinction between
these concepts, but they could be separated (with a fair amount of work).
@Koenkk Koenkk merged commit 519e123 into Koenkk:dev Jun 2, 2024
11 checks passed
@Koenkk
Copy link
Owner

Koenkk commented Jun 2, 2024

Thanks!

@agoode agoode deleted the occupancy branch June 3, 2024 00:14
ghoz pushed a commit to ghoz/zigbee2mqtt that referenced this pull request Jun 14, 2024
… sensors (Koenkk#22896)

'occupancy' matches the zigbee terminology more closely and is more
consistent with other Home Assistant entities of this type.

https://www.home-assistant.io/integrations/binary_sensor/

In general, it looks like 'motion' is more for alarms, and 'occupancy'
for non-alarm situations. Z2M currently makes no distinction between
these concepts, but they could be separated (with a fair amount of work).
@nikrays
Copy link

nikrays commented Jul 3, 2024

put everything back, now the motion sensor shows the "house" icon instead of the "running man"!

@agoode
Copy link
Contributor Author

agoode commented Jul 3, 2024

Yes, unfortunately there is not currently a separate category for "occupancy" vs "motion" in z2m. It would be more work to add this.

You can always override the type in Home Assistant, see https://www.home-assistant.io/docs/configuration/customizing-devices/

@nikrays
Copy link

nikrays commented Jul 3, 2024

Yes, unfortunately there is not currently a separate category for "occupancy" vs "motion" in z2m. It would be more work to add this.

You can always override the type in Home Assistant, see https://www.home-assistant.io/docs/configuration/customizing-devices/

so this is a temporary solution? Maybe I don’t need to change anything yet? Does this require some work on your part or on the home assistant side?

@agoode
Copy link
Contributor Author

agoode commented Jul 5, 2024

You can always override the type in Home Assistant, see https://www.home-assistant.io/docs/configuration/customizing-devices/

so this is a temporary solution? Maybe I don’t need to change anything yet? Does this require some work on your part or on the home assistant side?

Once you set the "shown as" explicitly in HA, then z2m won't change it again. So if you are ok with changing this manually once for each affected sensor, you should be all set. (Until there is a better solution, you'll need to do this manual step each time you configure a new sensor.)

Does this seem ok?

@ghoz
Copy link
Contributor

ghoz commented Jul 5, 2024

You can override the HA discovery on a device or global level in the z2m configuration.yaml

device_options:
  homeassistant:
    occupancy:
      device_class: motion

rather than changing it manually for each and every sensor.
I suppose you can also do it in the HA side in customize entity https://www.home-assistant.io/integrations/homeassistant/#editing-entity-settings-in-yaml

Right now there is no way to automatically identiy motion and real occupancy :-/

@GH2user
Copy link

GH2user commented Jul 30, 2024

Right now there is no way to automatically identiy motion and real occupancy :-/

But isn't the device used telling you what is should be?
A HUE motion sensor is motion, a mmwave sensor is occupancy and so on.

Just asking, stumbled in here as my icons changed after upgrading z2m.

@Broekman
Copy link

Broekman commented Aug 2, 2024

@Koenkk Might be an idea to introduce a breaking changes section in the release notes because this breaks every Home Assistant instance that uses device class/entity types in their scripts (e.g. a script getting all motion entities in an area).

Perhaps automatically generated in the notes by labeling such tickets as potentially breaking. Took me an hour to figure out why my scripts weren't working anymore after updating to 1.39 😅 I usually go through the release notes before updating but even I missed it (and most people probably just update blindly).

This is a small change, but it already affected four people in my direct bubble.

Thanks 😀

@Koenkk
Copy link
Owner

Koenkk commented Aug 3, 2024

@Broekman I was not aware this would be a breaking change, but it's too late to revert now

@agoode
Copy link
Contributor Author

agoode commented Aug 3, 2024

Yes, I didn't realize that either. Sorry about the unexpected churn.

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.

6 participants