Somfy-Developer / Somfy-TaHoma-Developer-Mode

A collection of requests to use a local API with Somfy TaHoma gateways
135 stars 12 forks source link

Remote events only appear on local events if different to the last event #128

Open AdyRock opened 6 months ago

AdyRock commented 6 months ago

When fetching local events, button presses on the IO remote (situ 1 pure II) only appear if the button pressed was different to last time. Therefore, pressing the up button more than once only provides one event until a different button is pressed. So: press up and get an event, press up again and nothing, press down and get an event, press down again and nothing, press up and get an event, press down and get an event, etc.

All events are returned via the old cloud API, so the problem is only apparent in the local API.

llavorel-somfy commented 4 months ago

Hi @AdyRock What is the event you are seeking ? And the one you are receiving ?

AdyRock commented 4 months ago

Hi @llavorel-somfy, it is the button pressed events of the situ1 pure ll.

On the Internet connection, I get every button press, albeit in batches every 30 seconds, but on the local connection, I only get one event as described above. So, I can't use the remote to dim a light, for example, via the local connection.

llavorel-somfy commented 4 months ago

Can you share the JSON payload you are expecting ?

AdyRock commented 4 months ago

As the remote didn't work correctly, I have put it away somewhere and can't find it at the moment, so I can't produce any logs.

However, the payload I'm expecting is from a call to get events with the button press information. If I press the up button 5 times, I expect to get one or more payloads that contain 5 button up events, but all I get from the local API is one event payload with one up button event, provide the last button I pressed wasn't an up button..

When the next cloud API event is requested it contains a payload with all 5 up button presses in it.

AdyRock commented 4 months ago

Hi @llavorel-somfy , I have found the remote and generated a log:

[
  {
    "time": "2024-06-03T08:39:27.394Z",
    "elapsed": 3.013,
    "source": "Local syncLoop",
    "data": "Logged in = true, Local = true, Old Sync State = false, Next cloud sync in 21s"
  },
  {
    "time": "2024-06-03T08:39:27.469Z",
    "elapsed": 0.075,
    "source": "Local Fetching Events",
    "data": "Complete"
  },
  {
    "time": "2024-06-03T08:39:30.493Z",
    "elapsed": 3.024,
    "source": "Local syncLoop",
    "data": "Logged in = true, Local = true, Old Sync State = false, Next cloud sync in 18s"
  },
  {
    "time": "2024-06-03T08:39:30.585Z",
    "elapsed": 0.092,
    "source": "Local Fetching Events",
    "data": "{
               "message": "Complete",
               "stack": [
                 {
                   "deviceURL": "io://device id",
                   "deviceStates": [
                     {
                       "type": 3,
                       "name": "io:OneWayControllerButtonState",
                       "value": "up"
                     }
                   ],
                   "name": "DeviceStateChangedEvent"
                 }
               ]
             }"
  },
  {
    "time": "2024-06-03T08:39:30.632Z",
    "elapsed": 0.02,
    "source": "Device status update",
    "data": "Complete"
  },
  {
    "time": "2024-06-03T08:39:33.646Z",
    "elapsed": 3.014,
    "source": "Local syncLoop",
    "data": "Logged in = true, Local = true, Old Sync State = false, Next cloud sync in 15s"
  },
  {
    "time": "2024-06-03T08:39:33.729Z",
    "elapsed": 0.083,
    "source": "Local Fetching Events",
    "data": "Complete"
  },
  {
    "time": "2024-06-03T08:39:36.745Z",
    "elapsed": 3.016,
    "source": "Local syncLoop",
    "data": "Logged in = true, Local = true, Old Sync State = false, Next cloud sync in 12s"
  },
  {
    "time": "2024-06-03T08:39:36.817Z",
    "elapsed": 0.072,
    "source": "Local Fetching Events",
    "data": "Complete"
  },
  {
    "time": "2024-06-03T08:39:39.837Z",
    "elapsed": 3.02,
    "source": "Local syncLoop",
    "data": "Logged in = true, Local = true, Old Sync State = false, Next cloud sync in 9s"
  },
  {
    "time": "2024-06-03T08:39:39.912Z",
    "elapsed": 0.075,
    "source": "Local Fetching Events",
    "data": "Complete"
  },
  {
    "time": "2024-06-03T08:39:42.941Z",
    "elapsed": 3.029,
    "source": "Local syncLoop",
    "data": "Logged in = true, Local = true, Old Sync State = false, Next cloud sync in 6s"
  },
  {
    "time": "2024-06-03T08:39:43.005Z",
    "elapsed": 0.064,
    "source": "Local Fetching Events",
    "data": "Complete"
  },
  {
    "time": "2024-06-03T08:39:46.024Z",
    "elapsed": 3.019,
    "source": "Local syncLoop",
    "data": "Logged in = true, Local = true, Old Sync State = false, Next cloud sync in 3s"
  },
  {
    "time": "2024-06-03T08:39:46.098Z",
    "elapsed": 0.074,
    "source": "Local Fetching Events",
    "data": "Complete"
  },
  {
    "time": "2024-06-03T08:39:46.110Z",
    "elapsed": 0.012,
    "source": "Cloud syncLoop",
    "data": "Logged in = true, Local = false, Old Sync State = false"
  },
  {
    "time": "2024-06-03T08:39:46.219Z",
    "elapsed": 0.109,
    "source": "Cloud Fetching Events",
    "data": "{
               "message": "Complete",
               "stack": [
                 {
                   "timestamp": 1717403968940,
                   "setupOID": "34f3a799-39e9-4a99-994c-7be46de25840",
                   "deviceURL": "io://device id",
                   "deviceStates": [
                     {
                       "name": "io:OneWayControllerButtonState",
                       "type": 3,
                       "value": "up"
                     }
                   ],
                   "name": "DeviceStateChangedEvent"
                 },
                 {
                   "timestamp": 1717403973670,
                   "setupOID": "34f3a799-39e9-4a99-994c-7be46de25840",
                   "deviceURL": "io://device id",
                   "deviceStates": [
                     {
                       "name": "io:OneWayControllerButtonState",
                       "type": 3,
                       "value": "up"
                     }
                   ],
                   "name": "DeviceStateChangedEvent"
                 },
                 {
                   "timestamp": 1717403978219,
                   "setupOID": "34f3a799-39e9-4a99-994c-7be46de25840",
                   "deviceURL": "io://device id",
                   "deviceStates": [
                     {
                       "name": "io:OneWayControllerButtonState",
                       "type": 3,
                       "value": "up"
                     }
                   ],
                   "name": "DeviceStateChangedEvent"
                 }
               ]
             }"
  },
  {
    "time": "2024-06-03T08:39:46.225Z",
    "elapsed": 0.006,
    "source": "Device status update",
    "data": "Checking events"
  },
  {
    "time": "2024-06-03T08:39:46.234Z",
    "elapsed": 0.009,
    "source": "Device status update",
    "data": "Complete"
  },

The log shows the local and cloud event polling, with the local polling occuring every 3 seconds and the cloud once. I pressed the Down button on the remote and then cleared the log. I then pressed the Up button 3 times with about a 3 second pause between each press, The log shows that the first Up button press was transferred via the local API event, but no more, while the cloud API returned all 3 presses.

llavorel-somfy commented 4 months ago

Hi @AdyRock are you trying to trigger actions on other equipment based on this event ?

AdyRock commented 4 months ago

Correct, I want to use the remote as a control for my lights via Homey.

rwzdoorn commented 3 months ago

Just a n00b question. Is this issue related to my KeyGo IO issue? I only use one button that I press to open and close my Dexxo Smart IO. When using a Smoove up and down button the status is being updated correctly. See https://github.com/Somfy-Developer/Somfy-TaHoma-Developer-Mode/issues/106 for more information.

llavorel-somfy commented 3 months ago

Hi @rwzdoorn I don't think this is related ... It is likely that the TaHoma doesn't catch the events from the KeyGo and therefore cannot fetch the new position of your motor.