hbblebc / homebridge-bed-control

Homebridge plugin to control compatible smart beds
Apache License 2.0
7 stars 2 forks source link

API Error: Cannot send the MCR request to Fuzion device #11

Open maustinstar opened 4 months ago

maustinstar commented 4 months ago

Hi, I tried using this plugin today, and I've had little success in reading bed status in home bridge, seeing the status in HomeKit, and changing the settings from HomeKit.

Describe The Bug:

With debug logs, I see API connection issues for getPumpStatus, getFoundationStatus, putAdjust, and putSleepNumber. They all have error 400 with Cannot send the MCR request to Fuzion device.

This seems like a sleep number internal error, I wonder if it's related to the sleep number model. As a hunch, my sleep number model does not have left/right split (details in repro steps below).

As a result, I've noticed HomeBridge accessories tab will show false values for a few seconds (value: 0 or 5 for everything) before eventually showing the correct sleep number settings values (it seems familyStatus is working). In the HomeKit app, I only see incorrect values (0 or 5 for everything) -- perhaps the API error aborts syncing with HomeKit? Attempting to change values with HomeKit results in the same error.

To Reproduce:

Seeing this after initial setup on latest version 1.3.8. (apply plugin config and clear cache?)

Sleep number model: P5 Sleep Number Smart Bed with FlexFit 2 Smart Adjustable Base

Note: I don't have a split king, so there are no left/right side controls for the head/foot positions. As a naive attempt at parsing this API error, is MCR == Multi Channel [..?] and Fuzion == combined bed? I tried linking a local version of this package and removing side param in putAdjust as an attempt, but still getting the same error.

Expected behavior:

  1. getPumpStatus and getFoundationStatus should not have error 400
  2. Homebridge probably shouldn't show temporary incorrect values on every refresh of the Accessories tab
  3. HomeKit should display the proper values that homebridge says
  4. Updates from HomeKit, putAdjust & putSleepNumber, should not have error 400

Logs:

[BedControl] [snapi][getPumpStatus][API Error] 400 Bad Request {
  Error: {
    Code: 400,
    Message: 'Cannot send the MCR request to Fuzion device'
  }
}
[BedControl] No data returned from the API. This is likely due to an issue with the API and should resolve itself soon.
[BedControl] No data returned from the API. This is likely due to an issue with the API and should resolve itself soon.

Plugin Config:

{
    "bedPlatform": "sleep number",
    "email": "<redacted>",
    "password": "<redacted>",
    "updateInterval": 60,
    "delay": 2,
    "ignore": [
        "-<redacted>.anySide.footwarming",
        "-<redacted>.anySide.light",
        "-<redacted>.anySide.outlet",
        "-<redacted>.anySide.responsiveAir",
        "-<redacted>.leftSide.footwarming",
        "-<redacted>.leftSide.light",
        "-<redacted>.leftSide.occupancySensor",
        "-<redacted>.leftSide.outlet",
        "-<redacted>.leftSide.responsiveAir",
        "-<redacted>.leftSide.footControl",
        "-<redacted>.leftSide.headControl",
        "-<redacted>.rightSide.footwarming",
        "-<redacted>.rightSide.light",
        "-<redacted>.rightSide.occupancySensor",
        "-<redacted>.rightSide.outlet",
        "-<redacted>.rightSide.responsiveAir"
    ],
    "platform": "BedControl"
}

Environment:

hbblebc commented 4 months ago

Hi, thanks for reporting. It does seem like you probably have a different base with a different set of API endpoints. If possible. could you use an app like Charles Proxy to extract the API web requests sent from the app? If I know the differences, I should be able to adapt the API to handle it.

In some cases, if there are not two sides to a function, they internally default to using the right side to represent the combined sides. If that is the case, you can often get away with hiding the left side and renaming the right side as you please.

But in this case, it sounds like there is more going on.