RavenSystem / esp-homekit-devices

Advanced firmware to add native Apple HomeKit and custom configurations, compatible with any SoC based on ESP32, ESP32-S, ESP32-C and ESP8266 series. (Shelly, Sonoff, Electrodragon, Tuya...)
Other
2.72k stars 357 forks source link

Garage door example - comprehension question about actions #1002

Closed MartinGaeumann closed 4 years ago

MartinGaeumann commented 4 years ago

Hi all

I have a question of understanding about the following JSON-line, which is taken from the garage door example: "2":{"r":[{"g":12,"i":1.5},{"g":12,"v":1,"i":0.5},{"g":12,"v":1,"i":2}]},

In my view:

The device (Sonoff SV) reacts correctly:

I can't figure out how the device reacts to the code. Can someone explain this to me?

Best regards Martin

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

tokamac commented 4 years ago

I don't understand neither why there are three consecutive activations of the relay for the opening command (and the last two are even two consecutive ON states aka "Drive output high").

But this is not the sole issue in the wiki about Garage door. Above the Actions table, the "Garage Door Example" part lists the four actions, where we can read:

door is closed and receives opening order ("2"), door is opening and receives closing order ("2")

so they have the same number! But due to the discrepancy between the Actions table and the code example, it is impossible to guess which one is really "1" or "2"…

EDIT: HAA configurator eventually gave the answer. The line: "2":{"r":[{"g":12,"i":1.5},{"g":12,"v":1,"i":0.5},{"g":12,"v":1,"i":2}]}, actually refers to "Door is opening and receives closing order"

So the correct sentence in the wiki should be: Door is opened and receives closing order ("0"), door is closed and receives opening order ("1"), [and not "2"] door is opening and receives closing order ("2") & door is closing and receives opening order ("3").

As "1" is the exact copy of "0" the open and close commands (when the door isn't already moving) are both exactly the same, which is normal as the systems works through a relay.

The Actions table in the wiki is correct.

The subtlety is that when the door is already moving and receives a counter-order, action "2" (and its exact copy for the other direction, action "3") does the following:

I think the first 1.5s delay where the relay must be OFF is there to be sure that no command is triggered while still being within the [0-0.5s] initial delay after the normal close "0" or open "1" commands. So there is a +1s security delay added to this 0.5 duration. The second command is the actual counter-order (relay ON for 0.5s) which makes the door go the other way. The third command (ON for 2s)… well, I still don't see what it does. Anyone?

RavenSystem commented 4 years ago

@tokamac I think your explanation is good.

door is closed and receives opening order ("2"), door is opening and receives closing order ("2")

Now it is fixed.

tokamac commented 4 years ago

Thanks but there seems to be another discrepancy with the sentence:

When the door is fully closed "f3" is triggered and then the door is fully open "f4" is triggered. GPIO 14 is used to indicate this state.

See the definition of "f4" in the State and Status Inputs table:

"f4" | Indicates that garage door is opening

Because fully open ≠ opening Thus either the code should trigger "f2" instead of "f4", or some definitions in the State and Status Inputs table are incorrect.

WizBangCrash commented 4 years ago

"f4" | Indicates that garage door is opening

Because fully open ≠ opening Thus either the code should trigger "f2" instead of "f4", or some definitions in the State and Status Inputs table are incorrect.

@tokamac Well spotted :-) I have updated the wiki to reflect that GPIO 14 indicates the closed state of the door.