nmaupu / yokis-hack

Some hacking regarding Yokis modules
Apache License 2.0
19 stars 4 forks source link

Driving single shutter #16

Open lecocotier opened 3 years ago

lecocotier commented 3 years ago

In my house I have a Yokis bus with 5 shutter devices. With a single remote, I use first button to close all, 2nd button to open all, and 3rd button to toggle a single device (1/5).

I tried to pair the single device with the button on the receptor. Got the following:

Hack started, click on the connect button when ready Waiting... timeout=30000 Buffer data: 49 FF 6 Buffer data: BB BB 47 11 6 Here are the info got from the device: Address: bb bb bb bb bb Channel: 47 Payload: 0 0 0 20 0 0 81 0 0 E2bp - TX OK E2bp - TX OK E2bp - TX OK E2bp - TX OK E2bp - TX OK E2bp - RX READY Received: 00100101 01000010 Device Status = OFF tempDevice - status=UNDEFINED Availability: Online mode: NO_RCP hw: BB BB channel: 47 serial/version: 11 6/49 FF 6

As it appeared NO_RCP, I forced to the following in the configuration:

BUTTON|bbbb|47|00|00|49ff06|1106|0003

So it's now a shutter device. When I drive it using yokis-hack, the problem is that all my shutter devices are driven, not only this one.

Tried to pair using the remote, here is what I get when I drive ALL shutters from the remote:

Hack started, click on the connect button when ready Waiting... timeout=30000 Buffer data: 49 0 A0 Buffer data: 1E 93 4D F5 86 Here are the info got from the device: Address: 1e 93 1e 93 93 Channel: 4D Payload: 0 0 0 20 0 0 14 0 0 E2bp - TX OK E2bp - TX OK E2bp - TX OK E2bp - TX OK E2bp - TX OK E2bp - TX OK E2bp - RX READY Received: 00101001 00000010 Device Status = OFF tempDevice - status=UNDEFINED Availability: Online mode: NO_RCP hw: 1E 93 channel: 4D serial/version: F5 86/49 0 A0

That's in configuration:

TCALL|1e93|4d|00|00|4900a0|f586|0003

And when I drive the single device using the remote:

Hack started, click on the connect button when ready Waiting... timeout=30000 Buffer data: 49 FF 6 Buffer data: BB BB 47 11 6 Here are the info got from the device: Address: bb bb bb bb bb Channel: 47 Payload: 0 0 0 20 0 0 81 0 0 E2bp - TX OK E2bp - TX OK E2bp - TX OK E2bp - TX OK E2bp - TX OK E2bp - RX READY Received: 00100101 01000010 Device Status = OFF tempDevice - status=UNDEFINED Availability: Online mode: NO_RCP hw: BB BB channel: 47 serial/version: 11 6/49 FF 6

That's in configuration:

TCUNO|bbbb|47|00|00|490020|1186|0003

So, at the end:

dConfig === Device === BUTTON - status=UNDEFINED Availability: Online mode: SHUTTER hw: BB BB channel: 47 serial/version: 11 6/49 FF 6

=== Device === TCUNO - status=UNDEFINED Availability: Online mode: SHUTTER hw: BB BB channel: 47 serial/version: 11 86/49 0 20

=== Device === TCALL - status=UNDEFINED Availability: Online mode: SHUTTER hw: 1E 93 channel: 4D serial/version: F5 86/49 0 A0

The problem is that, no matter if I try to drive BUTTON, TCUNO or TCALL, all the 5 shutter devices are moving.

lecocotier commented 3 years ago

Actually, the payload is wrong.

Looking at https://www.yokis.fr/wp-content/uploads/2020/02/memento-radio-yokis.pdf

There are direct commands or grouped command. In case of direct command to a shutter, 2nd byte is 0x06 In case of grouped command, 2nd byte is 0x16

0x16 is used to drive several shutter (grouped command)

Looking at the traffic when using the remote, 3rd byte was never 0x20, always 0x00. It's still working when sending 0x20, and I'm not sure about the purpose of that one.

So, for single shutter device: UP command: B9 6 0 0 0 0 ?? 0 0 PAUSE command: 1A 6 0 0 0 0 ?? 0 0 DOWN command: FA 6 0 0 0 0 ?? 0 0 TOGGLE command: 35 6 0 0 0 0 ?? 0 0 PAUSE command when TOGGLE command in effect: 53 6 0 0 0 0 ?? 0 0 RECALL preset position command: F4 6 0 0 0 0 0 0

For multiple shutter devices in the bus: UP command: B9 16 0 0 0 0 ?? 0 0 PAUSE command: 1A 16 0 0 0 0 ?? 0 0 DOWN command: FA 16 0 0 0 0 ?? 0 0 TOGGLE command: 35 16 0 0 0 0 ?? 0 0 PAUSE command when TOGGLE command in effect: 53 16 0 0 0 0 ?? 0 0 RECALL preset position command: F4 16 0 0 0 0 ?? 0 0

I believe similar behavior exists for other devices (ie: 0x04, 0x14 - didn't checked but there are not so many devices so maybe bit 9 is just 0 for single device and 1 for multiple devices on the bus).

Regarding pairing, I made several tests, and I can say the test done to identify shutter devices is not working.

When pairing, I got in buffer[0] for the same device and different ways (local button, remote ON single device, remote TOGGLE single device, remote OFF single device, remote ON multiple devices) various values such as: 0x14, 0x15, 0x09, 0x08, 0x04, 0x25.

Maybe it's better to let the user configure the devices through telnet for example (similar way to Yokis remote configuration: product type & direct or "grouped" command), and to use the 4 Yokis commands: 1) TOGGLE/PAUSE/TOGGLE 2) RECALL MEMORY 3) ON & UP/PAUSE 4) OFF & DOWN/PAUSE

nmaupu commented 3 years ago

I don't think this will work with a Yokis bus, you need to pair each shutter independently for this to work as expected I think.

lecocotier commented 3 years ago

Hi,

Yes, it's as you said, to drive single shutter I need to pair each one by one.

The problem is that all the shutters were already in a bus before, so if one receive the global command it will propagate it to the other on the bus.

I modified a bit your firmware to drive single shutters, didn't implement the global command integration (maybe I'll do it later) and added cover over mqtt so it appears properly as cover in Home Assistant. There is still room for new payloads to such as preset position, and getting back the cover status in Home Assistant, but I don't really need it now, my main goal was to be able to drive blindly my shutters over Home Assistant without replacing my Yokis modules.

I didn't touch the device detection part (switch on buffer[0]), but this is not working. Maybe there is no way to detect the device and user should configure it.

Thanks a lot for the work you did. As it was not working immediately, I had the opportunity to have a look at these "new" microcontrollers (didn't touch one since I was in school), the IDE is really nice and OTA programming is a gamechanger... Seems I will use them again for other small projects :)

ORelio commented 3 years ago

Hi,

Thank you very much for this nice little project which allowed me to play for once with microcontrollers instead of raspberry pi. I've been able to compile and setup everything thanks to the info present in the repository and issues (#9 and this one). The reverse engineering documentation was also an interesting read, congrats for your hard work :)

I however encountered the exact same issues as described here by @lecocotier as my shutters were not detected as shutters (need to adjust device type to 3 after pairing), and they are also set up as a bus so after pairing with an individual shutter, all shutters were controlled by the on/off commands.

The fix suggested above (sending 0x06 instead of 0x16 as second payload byte) works like a charm, thanks! In case you are interested for integrating the change in the main codebase, here is the related commit from https://github.com/ORelio/yokis-hack/commit/fd146300b39a349b46821753c76eb459e59ab474:

diff --git a/include/RF/device.h b/include/RF/device.h
index 974bad6..314bbaa 100644
--- a/include/RF/device.h
+++ b/include/RF/device.h
@@ -21,11 +21,12 @@
 // Depending on device, behavior can be different...
 // Still to figure out what can configure that in scanned protocol though.
 enum DeviceMode {
-    ON_OFF = 0,  // Reception: OFF=00 00, ON=00 01
-    DIMMER,   // Reception: 01 00 -> command not ok, 01 01 -> command ok (second
-              // payload) - first payload responds with device status
-    NO_RCPT,  // No reception, send blindly begin and end packets 30 times
-    SHUTTER   // Shutter style devices (MVR500)
+    ON_OFF = 0, // Reception: OFF=00 00, ON=00 01
+    DIMMER,     // Reception: 01 00 -> command not ok, 01 01 -> command ok
+                // (2nd payload) - first payload responds with device status
+    NO_RCPT,    // No reception, send blindly begin and end packets 30 times
+    SHUTTER,    // Shutter style devices (MVR500) single device
+    SHUTTER_BUS // Shutter style devices (MVR500) one or more devices on a bus
 };

 enum DeviceStatus { OFF = 0, ON, UNDEFINED, PAUSE_SHUTTER };
diff --git a/src/RF/e2bp.cpp b/src/RF/e2bp.cpp
index ba8a399..0dbb53c 100644
--- a/src/RF/e2bp.cpp
+++ b/src/RF/e2bp.cpp
@@ -269,7 +269,19 @@ bool E2bp::pressAndHoldFor(unsigned long duration) {
 // Fill a given buffer with the correct payload and return a pointer to it
 uint8_t* E2bp::getPayload(uint8_t* buf, PayloadType type) {
     buf[0] = 0x00;
-    buf[1] = device->getMode() == SHUTTER ? 0x16 : 0x04;
+
+    switch (device->getMode()) {
+        case SHUTTER:
+            buf[1] = 0x06;
+            break;
+        case SHUTTER_BUS:
+            buf[1] = 0x16;
+            break;
+        default:
+            buf[1] = 0x04;
+            break;
+    }
+
     buf[2] = 0x00;
     buf[3] = 0x20;
     buf[4] = device->getHardwareAddress()[0];
@@ -291,7 +303,15 @@ uint8_t* E2bp::getPayload(uint8_t* buf, PayloadType type) {
             buf[0] = YOKIS_CMD_ON;
             break;
         case PL_OFF:
-            buf[0] = device->getMode() == SHUTTER ? YOKIS_CMD_OFF_SHUTTER : YOKIS_CMD_OFF;
+            switch (device->getMode()) {
+                case SHUTTER:
+                case SHUTTER_BUS:
+                    buf[0] = YOKIS_CMD_OFF_SHUTTER;
+                    break;
+                default:
+                    buf[0] = YOKIS_CMD_OFF;
+                    break;
+            }
             break;
         case PL_STATUS:
             buf[0] = 0;

Instead of just changing the payload and removing support for bus command, I moved it to a different device type (0x04), so it's possible to pair with any shutter in the bus and set data type to 4 instead of 3 to send shutter bus commands.

I cannot really test and contribute to #18 because my shutters are V4 (gray version), not V5 (green version), and it seems like (comments) V4 does not implement status feedback (cannot check status of the shutters, only send commands). Indeed, the status command in Yokis-Hack always reports OFF for my shutters. However, I can confirm switching between 0x06 and 0x16 works for controlling either a single shutter or a bus.

If you have shutter-related changes and need help testing, feel free to ping me 😉

nmaupu commented 2 years ago

Thanks for your feedback, I will try to integrate this when I get the chance !

ORelio commented 2 years ago

Okay! Just in case you're interested I've also added a simple flag to disable Wi-Fi in https://github.com/ORelio/yokis-hack/commit/d084f30e78a45191f5b2f325c925cb2ef85489a9 because I'm driving the ESP directly through serial over USB. If you're interested I can submit a PR but it's really a simple change 😉

EinarBergsson commented 1 year ago

Hey all! I have a rather old setup, that I need to revamp. I am gathering the connections string (using dConfig and dRestore), but one of my gateways has really old firmware on it. How do I convert this:

=== Device === shutter01 - status=OFF Availability: Online mode: SHUTTER hw: 73 3F channel: 37 serial/version: D5 6/49 FF 6

=== Device === shutter02 - status=OFF Availability: Online mode: SHUTTER hw: 24 A0 channel: 19 serial/version: BB 6/49 FF 6

To the new format for dRestore???

ORelio commented 1 year ago

I'm not sure. This looks correctly formatted. You could try pairing one shutter and exporting with the latest version and comparing the format to adjust your older export.

nmaupu commented 1 year ago

Here is the format from the master : https://github.com/nmaupu/yokis-hack/blob/c876cd3e2a56de171a49c5d66bc662cedfa92443/src/RF/device.cpp#L340

SEP is the | char

I don't recall changing it though...

EinarBergsson commented 1 year ago

It was just me being stupid. One of them was not set to give RAW results. (try changing to raw or not raw and the result is not the same on dConfig). Anyway. It is sorted now. On to the next issue.

EinarBergsson commented 1 year ago

Okay! Just in case you're interested I've also added a simple flag to disable Wi-Fi in ORelio@d084f30 because I'm driving the ESP directly through serial over USB. If you're interested I can submit a PR but it's really a simple change 😉

Wait, how do you do that?? I might be interested as I suspect that my NodeMCU is killing the range on the YOKIS connection. I noticed that it did the same with my phone.

EinarBergsson commented 1 year ago

OK that did not take long... It seems that the hack is not registering a subject to be controlled by mqtt. If I send the command there it will not work, and the mosquito log suggests that the hack never registers a subscription for the devices.

Any bright ideas on this?!

ORelio commented 1 year ago

Wait, how do you do that??

Disabling Wi-Fi: Apply this commit or clone my repo https://github.com/ORelio/yokis-hack/commit/d084f30e78a45191f5b2f325c925cb2ef85489a9

Controlling over serial: You can connect using screen: screen /dev/ttyUSB0 115200 and type commands there. To disconnect, use Ctrl+A followed by :quit command. Any program interfacing with serial can control the device over serial.

About MQTT: I don't know, because I'm not using MQTT. I do on devicename, off devicename over serial.

nmaupu commented 1 year ago

you can't do MQTT if you disable wifi

EinarBergsson commented 1 year ago

I have not disabled Wifi yet... I know I look it but I am not that daft. :).

What is happening is that the gateway is publishing stuff, but just not subscribing to the control subjects so I cannot issue an "on" or "off" to the devices.

nmaupu commented 1 year ago

Subscription is done here : https://github.com/nmaupu/yokis-hack/blob/c876cd3e2a56de171a49c5d66bc662cedfa92443/src/net/mqttHass.cpp#L61

It has been created for lights so it might not work for shutters. It should be seen as a switch... I don't know much about it because I never used shutters! Maybe you can try to tamper the json and try to publish something yourself so that you can better test and see what's actually working?

lecocotier commented 1 year ago
Hi,
It's done on my branch
        } else if (device->getMode() == SHUTTER) {
          sprintf(buf,
                  "{"
                  "\"name\":\"Shutter %s\","
                  "\"optimistic\":\"false\","  // if false, cannot
  know the status
                                               // of the device
                  "\"cmd_t\":\"~cmnd/POWER\","
                  "\"state_topic\":\"~tele/STATE\","
                  "\"val_tpl\":\"{{value_json.POWER}}\","
  //                "\"tilt_status_topic\": \"~tele/TILT\","
  //               
  "\"tilt_status_template\":\"{{value_json.TILT}}\","
                  "\"avty_t\":\"~tele/LWT\","
                  "\"pl_avail\":\"Online\","
                  "\"pl_not_avail\":\"Offline\","
                  "\"payload_close\":\"OFF\","
                  "\"payload_open\":\"ON\","
                  "\"payload_stop\":\"PAUSE\","
                  "\"uniq_id\":\"esp-%s\","
                  "\"device\":{"
                  "\"name\":\"%s\","
                  "\"identifiers\":[\"esp-%s\"],"
                  "\"model\":\"MVR500ERP \","
                  "\"mf\":\"Yokis\""
                  "},"
                  "\"~\":\"%s/\""
                  "}",
                  device->getName(), device->getName(),
  device->getName(),
                  device->getName(), device->getName());
          } else {
Regards,

François
Le 23/02/2023 à 21:43, Nicolas Maupu a
  écrit :

  Subscription is done here :
    https://github.com/nmaupu/yokis-hack/blob/c876cd3e2a56de171a49c5d66bc662cedfa92443/src/net/mqttHass.cpp#L61
  It has been created for lights so it might not work
    for shutters. It should be seen as a switch...
    I don't know much about it because I never used shutters!
    Maybe you can try to tamper the json and try to publish
    something yourself so that you can better test and see what's
    actually working?
  —
    Reply to this email directly, view it on GitHub, or unsubscribe.
    You are receiving this because you were mentioned.Message
      ID: ***@***.***>
  [

{ @.": "http://schema.org", @.": "EmailMessage", "potentialAction": { @.": "ViewAction", "target": "https://github.com/nmaupu/yokis-hack/issues/16#issuecomment-1442405833", "url": "https://github.com/nmaupu/yokis-hack/issues/16#issuecomment-1442405833", "name": "View Issue" }, "description": "View this Issue on GitHub", "publisher": { @.": "Organization", "name": "GitHub", "url": "https://github.com" } } ]

nmaupu commented 1 year ago

Hi, It's done on my branch         } else if (device->getMode() == SHUTTER) {         sprintf(buf,                 "{"                 "\"name\":\"Shutter %s\","                 "\"optimistic\":\"false\","  // if false, cannot know the status                                              // of the device                 "\"cmd_t\":\"~cmnd/POWER\","                 "\"state_topic\":\"~tele/STATE\","                 "\"val_tpl\":\"{{value_json.POWER}}\"," //                "\"tilt_status_topic\": \"~tele/TILT\"," //                "\"tilt_status_template\":\"{{value_json.TILT}}\","                 "\"avty_t\":\"~tele/LWT\","                 "\"pl_avail\":\"Online\","                 "\"pl_not_avail\":\"Offline\","                 "\"payload_close\":\"OFF\","                 "\"payload_open\":\"ON\","                 "\"payload_stop\":\"PAUSE\","                 "\"uniq_id\":\"esp-%s\","                 "\"device\":{"                 "\"name\":\"%s\","                 "\"identifiers\":[\"esp-%s\"],"                 "\"model\":\"MVR500ERP \","                 "\"mf\":\"Yokis\""                 "},"                 "\"~\":\"%s/\""                 "}",                 device->getName(), device->getName(), device->getName(),                 device->getName(), device->getName());         } else { Regards, François Le 23/02/2023 à 21:43, Nicolas Maupu a écrit : Subscription is done here : https://github.com/nmaupu/yokis-hack/blob/c876cd3e2a56de171a49c5d66bc662cedfa92443/src/net/mqttHass.cpp#L61 It has been created for lights so it might not work for shutters. It should be seen as a switch... I don't know much about it because I never used shutters! Maybe you can try to tamper the json and try to publish something yourself so that you can better test and see what's actually working? — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.> [ { @.": "http://schema.org", @.": "EmailMessage", "potentialAction": { @.": "ViewAction", "target": "#16 (comment)", "url": "#16 (comment)", "name": "View Issue" }, "description": "View this Issue on GitHub", "publisher": { @.***": "Organization", "name": "GitHub", "url": "https://github.com" } } ]

Nice, should be nice to have a real PR about that ;)

lecocotier commented 1 year ago
I'm not a coder an did that long time ago, it has never been
  really finished (I think I wanted to implement gateway commands
  and never did it), but was actually ok for my needs as I'm using
  it for 2 years or so.
If someone wants to merge feel free, I just don't really remember
  what I did anymore. In such case let me know because my branch may
  be outdated.

François
Le 23/02/2023 à 21:48, Nicolas Maupu a
  écrit :

    Hi, It's done on my branch         } else if
      (device->getMode() == SHUTTER) {         sprintf(buf,
                      "{"                 ""name":"Shutter %s","
                      ""optimistic":"false","  // if false, cannot
      know the status                                             
      // of the device                 ""cmd_t":"~cmnd/POWER","
                      ""state_topic":"~tele/STATE","                
      ""val_tpl":"{{value_json.POWER}}"," //               
      ""tilt_status_topic": "~tele/TILT"," //               
      ""tilt_status_template":"{{value_json.TILT}}","
                      ""avty_t":"tele/LWT","                
        ""pl_avail":"Online","                
        ""pl_not_avail":"Offline","                
        ""payload_close":"OFF","                
        ""payload_open":"ON","                
        ""payload_stop":"PAUSE","                
        ""uniq_id":"esp-%s","                 ""device":{"
                        ""name":"%s","                
        ""identifiers":["esp-%s"],"                
        ""model":"MVR500ERP ","                 ""mf":"Yokis""
                        "},"                 """:"%s/""
                      "}",                 device->getName(),
      device->getName(), device->getName(),                
      device->getName(), device->getName());         } else {
      Regards, François Le 23/02/2023 à 21:43, Nicolas Maupu a
      écrit : Subscription is done here : https://github.com/nmaupu/yokis-hack/blob/c876cd3e2a56de171a49c5d66bc662cedfa92443/src/net/mqttHass.cpp#L61
      It has been created for lights so it might not work for
      shutters. It should be seen as a switch... I don't know much
      about it because I never used shutters! Maybe you can try to
      tamper the json and try to publish something yourself so that
      you can better test and see what's actually working? — Reply
      to this email directly, view it on GitHub, or unsubscribe. You
      are receiving this because you were mentioned.Message ID: @.>
          [ { @.":
      "http://schema.org", @.":
          "EmailMessage", "potentialAction": { @.":
      "ViewAction", "target": "#16 (comment)", "url": "#16 (comment)", "name": "View
      Issue" }, "description": "View this Issue on GitHub",
      "publisher": { @.***":
      "Organization", "name": "GitHub", "url": "https://github.com"
      } } ]

  Nice, should be nice to have a real PR about that ;)
  —
    Reply to this email directly, view it on GitHub, or unsubscribe.
    You are receiving this because you were mentioned.Message
      ID: ***@***.***>
  [

{ @.": "http://schema.org", @.": "EmailMessage", "potentialAction": { @.": "ViewAction", "target": "https://github.com/nmaupu/yokis-hack/issues/16#issuecomment-1442410152", "url": "https://github.com/nmaupu/yokis-hack/issues/16#issuecomment-1442410152", "name": "View Issue" }, "description": "View this Issue on GitHub", "publisher": { @.": "Organization", "name": "GitHub", "url": "https://github.com" } } ]

nmaupu commented 1 year ago

As I am traveling right now without any computer, I can't do much about that until Sept. :/ Best way is for @EinarBergsson to compile a bin from your branch then...

lecocotier commented 1 year ago
It could, just quickly checked and my branch is actually
  outdated, and I don't remember if my bin is from my branch or from
  my local source.
I think I did some changes to update the status feedback of the
  shutter according to last command if it's not sending it (depends
  on the device).
Again, it's old..

François
Le 23/02/2023 à 22:06, Nicolas Maupu a
  écrit :

  As I am traveling right now without any computer, I
    can't do much about that until Sept. :/
    Best way is for @EinarBergsson
    to compile a bin from your branch then...
  —
    Reply to this email directly, view it on GitHub, or unsubscribe.
    You are receiving this because you were mentioned.Message
      ID: ***@***.***>
  [

{ @.": "http://schema.org", @.": "EmailMessage", "potentialAction": { @.": "ViewAction", "target": "https://github.com/nmaupu/yokis-hack/issues/16#issuecomment-1442432420", "url": "https://github.com/nmaupu/yokis-hack/issues/16#issuecomment-1442432420", "name": "View Issue" }, "description": "View this Issue on GitHub", "publisher": { @.": "Organization", "name": "GitHub", "url": "https://github.com" } } ]

lecocotier commented 1 year ago
I think this is only local. It's not really ready for PR because
  I put perm debug on some stuff, but that's probably what is on my
  bin.
Einar if you want my src let me know.

//        if (IS_DEBUG_ENABLED) {            LOG.print("Received: ");            LOG.print(device->getName());            LOG.print(" (");            LOG.print(device->getModeAsString(device->getMode()));            LOG.print(") ");            printBinaryRepresentation(answerBuf[0], true);            LOG.print(" ");            printBinaryRepresentation(answerBuf[1], true);            LOG.print(" - Time: ");            LOG.print(millis());            LOG.print(" - Last cmd: ");            LOG.print(device->getLastCmdTime());            LOG.print(" - Delta: ");            LOG.print(millis()-device->getLastCmdTime());            LOG.print(" - Previous: ");            LOG.print(device->getStatusAsString(device->getStatus()));            LOG.print(" - Current: ");//        }

        // MVR500 window open and delay ok  00 10 11 11 - 00 00 00 10 10 = delay ok        // MVR500 window close and delay ok 00 01 11 10 - 00 00 00 10 10 = delay ok        // MVR500 window open and pause     00 00 11 11 - 00 00 00 10        // MVR500 send open or close the answerbuf take *** - 00 00 00 11 busy        // MVR500 after pair send status when window open 00 00 11 10 - 00 00 00 10        //         // Seems there is various way of devices answering different ways. Trying to cover all.        // Devices answering 00 00 gives the same answer when closed/opened or paused. So if last command was a pause we suppose it's gone through:        // if shutter stops within 500 ms we consider it's in intermediate position.        // The local stop case, or though another remote, can't be taken in account...         if ( device->getMode() == SHUTTER ) {            if (firstPayloadStatus == UNDEFINED) {                if (                         // Open feedback of most device                        ((answerBuf[0] & 0x21) == 0x21 && answerBuf[1] == 0x02)                         ||                        // Some devices reports 0x0100 for open feedback or paused on the way up                        // So if we sent a stop command within 500 ms or if device is already stopped                        // we don't change the status                        (answerBuf[0] == 0x01 &&                         answerBuf[1] == 0x00  &&                         !((device->getLastShutterCmdSent()==PAUSE && (millis()-device->getLastCmdTime()) < 5000) || device->getStatus()==SHUTTER_STOPPED) )                ) {                    firstPayloadStatus = SHUTTER_OPENED;                    LOG.println("Opened");                } else if (                         ((answerBuf[0] & 0x11) == 0x10 && answerBuf[1] == 0x02)                     ||                         (answerBuf[0] == 0x00 && answerBuf[1] == 0x00 &&                         !((device->getLastShutterCmdSent()==PAUSE && (millis()-device->getLastCmdTime()) < 5000) || device->getStatus()==SHUTTER_STOPPED) )                ) {                    firstPayloadStatus = SHUTTER_CLOSED;                    LOG.println("Closed");                } else if ( ((answerBuf[0] & 0x01) == 0x01 && answerBuf[1] == 0x03) || (answerBuf[0] == 0x01 && answerBuf[1] == 0x01) ) {                    firstPayloadStatus = SHUTTER_OPENING;                    LOG.println("Opening");                } else if (((answerBuf[0] & 0x01) == 0x00 && answerBuf[1] == 0x03) || (answerBuf[0] == 0x00 && answerBuf[1] == 0x01) ) {                    firstPayloadStatus = SHUTTER_CLOSING;                    LOG.println("Closing");                } else if (                         (answerBuf[1] == 0x02)                     ||                         ((answerBuf[0] == 0x01 || answerBuf[0] == 0x00) &&                         answerBuf[1] == 0x00 &&                        ((device->getLastShutterCmdSent()==PAUSE && (millis()-device->getLastCmdTime()) < 5000) || device->getStatus()==SHUTTER_STOPPED)                        )                     ) {                    firstPayloadStatus = SHUTTER_STOPPED;                    LOG.println("Stopped");                }            }        } else {            if (firstPayloadStatus == UNDEFINED) {                if (answerBuf[1] == 1 || answerBuf[0] == 0x2f) {                    firstPayloadStatus = ON;                    LOG.println("On");                } else {                    firstPayloadStatus = OFF;                    LOG.println("Off");                }            } else {                if (answerBuf[1] == 1 || answerBuf[0] == 0x2f) {                    secondPayloadStatus = ON;                    LOG.println("On");                } else {                    secondPayloadStatus = OFF;                    LOG.println("Off");                }            }        }    }     return !loopContinue;  // false if timeout occurred}

François
Le 23/02/2023 à 22:06, Nicolas Maupu a
  écrit :

  As I am traveling right now without any computer, I
    can't do much about that until Sept. :/
    Best way is for @EinarBergsson
    to compile a bin from your branch then...
  —
    Reply to this email directly, view it on GitHub, or unsubscribe.
    You are receiving this because you were mentioned.Message
      ID: ***@***.***>
  [

{ @.": "http://schema.org", @.": "EmailMessage", "potentialAction": { @.": "ViewAction", "target": "https://github.com/nmaupu/yokis-hack/issues/16#issuecomment-1442432420", "url": "https://github.com/nmaupu/yokis-hack/issues/16#issuecomment-1442432420", "name": "View Issue" }, "description": "View this Issue on GitHub", "publisher": { @.": "Organization", "name": "GitHub", "url": "https://github.com" } } ]

lecocotier commented 1 year ago
Sorry for the spam, now I remember where I was with these
  shutters.
Some devices are reporting 0 when stopped or closed, that's the
  case for VrSalon here:

Some other devices are reporting intermediate position with a
  different status, that's the case for VrBureau here:

In both cases, shutter are initially closed and I send open
  command, followed by a pause command through HA, then a close
  command.
For VrSalon I end up showing opened status even if it's in
  intermediate position, I think I ended up being ok with that, and
  was trying to see if I could improve this by looking at time since
  last command and memorization, so that's basically the status of
  my sources that are in used on my version, but not on my git.
Hope it may help other shutters players.
François
Le 23/02/2023 à 22:06, Nicolas Maupu a
  écrit :

  As I am traveling right now without any computer, I
    can't do much about that until Sept. :/
    Best way is for @EinarBergsson
    to compile a bin from your branch then...
  —
    Reply to this email directly, view it on GitHub, or unsubscribe.
    You are receiving this because you were mentioned.Message
      ID: ***@***.***>
  [

{ @.": "http://schema.org", @.": "EmailMessage", "potentialAction": { @.": "ViewAction", "target": "https://github.com/nmaupu/yokis-hack/issues/16#issuecomment-1442432420", "url": "https://github.com/nmaupu/yokis-hack/issues/16#issuecomment-1442432420", "name": "View Issue" }, "description": "View this Issue on GitHub", "publisher": { @.": "Organization", "name": "GitHub", "url": "https://github.com" } } ]