home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.34k stars 30.64k forks source link

Make Occupancy sensor states consistent with trigger and condition strings #129566

Open NoRi2909 opened 3 days ago

NoRi2909 commented 3 days ago

The problem

All binary sensors for hazards inherit the On and Off state from the Gas binary sensor type as this matches well for Smoke, CO, Heat etc., too.

But currently this is also the case for Occupancy sensors which are not reporting a hazard at all but rather a simple state of a room. But having them inherit the same strings like smoke detectors causes quite some issues in translations where this results in the translation of the "clear" state (or "cleared" logbook entry) being changed back and forth many times as it does not fit across the board.

The inheritance is specified here:

https://github.com/home-assistant/core/blob/2bd5039f28e639439dfd6da216f51921072395f3/homeassistant/components/binary_sensor/strings.json#L222-L226

This results in

  "off": "Clear", 
  "on": "Detected", 

In English this is still quite obvious, but note that the trigger and condition types have already diverted from "Has started detecting occupation" or "Is detecting occupation" etc. to the special "became occupied" or "is not occupied" instead:

https://github.com/home-assistant/core/blob/2bd5039f28e639439dfd6da216f51921072395f3/homeassistant/components/binary_sensor/strings.json#L29-L30

https://github.com/home-assistant/core/blob/2bd5039f28e639439dfd6da216f51921072395f3/homeassistant/components/binary_sensor/strings.json#L29-L30

Therefore the states above should also be decoupled from the binary Gas sensor type by either using

  "off": "Not occupied", 
  "on": "Occupied", 

making them consistent with the existing trigger and condition types.

Or by changing all occurrences of "not occupied" in above triggers and conditions to "clear", keeping that for the "off" state. Then we'd have:

  "off": "Clear", 
  "on": "Occupied", 

Background: I'm reporting this because in German we had run into a major chaos because the first translation of that "Clear" state was set to "Leeren" ("to empty") which made absolutely no sense when it appeared in context. Then it was changed to "Normal" later on, but that does not fit for occupancy or motion sensors at all.

I've now changed this to "Frei" which works for everything except for motion where I set the off state to "Keine" (none).

So for occupancy here we now toggle between

  "off": "Frei", 
  "on": "Belegt", 

This also exactly matches the German translations of the triggers and conditions now (as suggested for English above) so everything is 100% consistent now.

I assume there will be similar issues in other languages, so some guidance from the English originals might help a lot here. For openings there is already separate strings which might the example to point at, too.

What version of Home Assistant Core has the issue?

2024.11.0b0

Integration causing the issue

Binary sensor

Link to integration documentation on our website

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

home-assistant[bot] commented 3 days ago

Hey there @home-assistant/core, mind taking a look at this issue as it has been labeled with an integration (binary_sensor) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `binary_sensor` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign binary_sensor` Removes the current integration label and assignees on the issue, 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 issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


binary_sensor documentation binary_sensor source (message by IssueLinks)

epenet commented 3 days ago

That makes sense - I suggest that you open a PR...