apple / HomeKitADK

Apache License 2.0
2.56k stars 232 forks source link

Question regarding the Position State characteristic #70

Closed rojer closed 4 years ago

rojer commented 4 years ago

(This is not an ADK question as such but maybe you can answer it or at least direct me where to ask it instead)

Window Covering service includes a Position State characteristic that has three possible values:

0 ”Going to the minimum value specified in metadata” 1 ”Going to the maximum value specified in metadata” 2 ”Stopped”

In the context of the window covering service, I read 0 to mean "Going to fully closed position (0%)" and 1 to mean "Going to fully open state (100%)" - this is what "metadata" (i.e. spec) defines as maximum and minimum values for the target and current positions. However, it's not clear to me what this characteristic should report when the curtain is moving to an intermediate position - e.g., user moved the slider to 60%, Home app sent a write to target position with value 60 and we are moving now, so we are not stopped. However, we are not moving to the 100% position so we can't say we are moving to the minimum or the maximum value. What should an accessory report in that case?

Clovel commented 4 years ago

Interesting question.

Perhaps this feature wasn’t initially meant to set the position to an intermediate state. Maybe we need to update this.

Have you studied the specs and the code to see if there is any indication that an intermediate position is a supported order ?

Le 7 oct. 2020 à 19:59, Deomid Ryabkov notifications@github.com a écrit :

 (This is not an ADK question as such but maybe you can answer it or at least direct me where to ask it instead)

Window Covering service includes a Position State characteristic that has three possible values:

0 ”Going to the minimum value specified in metadata” 1 ”Going to the maximum value specified in metadata” 2 ”Stopped”

In the context of the window covering service, I read 0 to mean "Going to fully closed position (0%)" and 1 to mean "Going to fully open state (100%)" - this is what "metadata" (i.e. spec) defines as maximum and minimum values for the target and current positions. However, it's not clear to me what this characteristic should report when the curtain is moving to an intermediate position - e.g., user moved the slider to 60%, Home app sent a write to target position with value 60 and we are moving now, so we are not stopped. However, we are not moving to the 100% position so we can't say we are moving to the minimum or the maximum value. What should an accessory report in that case?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

Supereg commented 4 years ago

Afaik PositionState just says in which direction the window (or window covering) is moving. I think only the language in the spec is a bit misleading.

0: closing 1: opening 2: stopped

May be wrong. But that's how I would have interpreted it (and have implemented it some months back). Can double check what behavior im seeing with one of my certified HomeKit windows.

maximkulkin commented 4 years ago

@rojer ^^ @Supereg is correct: if it's moving (assuming it always tries to get to target position), when current position is greater than target position, position state should be set to 0; if current position is less than target position, positions state should be 1. If current position equal to target position, it should be set to 2.

rojer commented 4 years ago

@maximkulkin this makes sense intuitively but do you have a reference, perhaps?

Clovel commented 4 years ago

Would it make sense to modify the code to order an intermediate state ? Like 60% as OP said ?

Le 7 oct. 2020 à 20:29, Clovis Durand cd.clovel19@gmail.com a écrit :

 Interesting question.

Perhaps this feature wasn’t initially meant to set the position to an intermediate state. Maybe we need to update this.

Have you studied the specs and the code to see if there is any indication that an intermediate position is a supported order ?

Le 7 oct. 2020 à 19:59, Deomid Ryabkov notifications@github.com a écrit :

 (This is not an ADK question as such but maybe you can answer it or at least direct me where to ask it instead)

Window Covering service includes a Position State characteristic that has three possible values:

0 ”Going to the minimum value specified in metadata” 1 ”Going to the maximum value specified in metadata” 2 ”Stopped”

In the context of the window covering service, I read 0 to mean "Going to fully closed position (0%)" and 1 to mean "Going to fully open state (100%)" - this is what "metadata" (i.e. spec) defines as maximum and minimum values for the target and current positions. However, it's not clear to me what this characteristic should report when the curtain is moving to an intermediate position - e.g., user moved the slider to 60%, Home app sent a write to target position with value 60 and we are moving now, so we are not stopped. However, we are not moving to the 100% position so we can't say we are moving to the minimum or the maximum value. What should an accessory report in that case?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

rojer commented 4 years ago

i guess this rather calls for modification of the spec. Maxim's comment makes the most sense to me.

maximkulkin commented 4 years ago

@Clovel you're missing the point. Control of position is done through a different characteristic - target position. Position state is a readonly characteristic that, I guess, is used to show visual indication of accessory doing the motion.

AramVartanyan commented 4 years ago

It is exactly as Maxim pointed. Just look at “state closing” (0) as Decreasing and at “state opening” (1) as Increasing. Also you have “current position” and “target position”, which are giving the exact position in percentage from 0 to 100.

In the case you have described earlier, the accessory will be seen as “Opening” or “Closing” until it actually reaches the target value (the current value becomes equal to the target value - 60%). It is that simple.

rojer commented 4 years ago

ok, looks like we have a consensus here. thanks everyone, i made changes to my code to reflect this (https://github.com/mongoose-os-apps/shelly-homekit/commit/eb00f25dafe96f37b7f0904c40f34ebbec951990).