Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Blind Tilts won't change mapping modes based on mode changes in Homebridge #670

Closed
The-Croz opened this issue Feb 1, 2023 · 9 comments
Assignees
Labels
bug Something isn't working OpenAPI Issue dealing with OpenAPI (SwitchBotAPI)

Comments

@The-Croz
Copy link

The-Croz commented Feb 1, 2023

Describe The Bug

Blind tilts are set up to only down mode but mapping mode stays at only up and HK closes them up.

To Reproduce

Change mode in Homebridge config and the blinds don't change to the mode that is set

Expected behavior

Blinds will open to middle and close down

Relevant log output

[1/29/2023, 4:17:54 PM] [SwitchBot] Blind Tilt: Playroom Front R Blinds Config: {"mode":"only_down","connectionType":"OpenAPI","logging":"standard","mappingMode":"only_up"}
[1/29/2023, 4:17:54 PM] [SwitchBot] Blind Tilt: Playroom Side Blinds Config: {"mode":"only_down","connectionType":"OpenAPI","logging":"standard","mappingMode":"only_up"}
[1/29/2023, 4:17:54 PM] [SwitchBot] Blind Tilt: Front Room R Blinds Config: {"mode":"only_down","connectionType":"OpenAPI","logging":"standard","mappingMode":"only_up"}
[1/29/2023, 4:17:54 PM] [SwitchBot] Blind Tilt: Playroom Front L Blinds Config: {"mode":"only_down","connectionType":"OpenAPI","logging":"standard","mappingMode":"only_up"}
[1/29/2023, 4:17:54 PM] [SwitchBot] Blind Tilt: Front Room L Blinds Config: {"mode":"only_down","connectionType":"OpenAPI","logging":"standard","mappingMode":"only_up"}

Config for homebridge-switchbot

{
  "_bridge" : {
    "port" : 59408,
    "username" : ""
  },
  "credentials" : {
    "notice" : "Keep your Token & Secret a secret!",
    "secret" : "",
    "token" : ""
  },
  "name" : "SwitchBot",
  "options" : {
    "devices" : [
      {
        "blindTilt" : {
          "mode" : "only_down"
        },
        "configDeviceName" : "Front Room L Blinds",
        "configDeviceType" : "Blind Tilt",
        "connectionType" : "OpenAPI",
        "deviceId" : "EAB32AD5C091",
        "hide_device" : false,
        "logging" : "standard"
      },
      {
        "blindTilt" : {
          "mode" : "only_down"
        },
        "configDeviceName" : "Front Room R Blinds",
        "configDeviceType" : "Blind Tilt",
        "connectionType" : "OpenAPI",
        "deviceId" : "E1D37758EC8C",
        "logging" : "standard"
      },
      {
        "blindTilt" : {
          "mode" : "only_down"
        },
        "configDeviceName" : "Playroom Front L Blinds",
        "configDeviceType" : "Blind Tilt",
        "connectionType" : "OpenAPI",
        "deviceId" : "E2DE0F01870C",
        "logging" : "standard"
      },
      {
        "blindTilt" : {
          "mode" : "only_down"
        },
        "configDeviceName" : "Playroom Front R Blinds",
        "configDeviceType" : "Blind Tilt",
        "connectionType" : "OpenAPI",
        "deviceId" : "C16B0F3CDA7A",
        "logging" : "standard"
      },
      {
        "blindTilt" : {
          "mode" : "only_down"
        },
        "configDeviceName" : "Playroom Side Blinds",
        "configDeviceType" : "Blind Tilt",
        "connectionType" : "OpenAPI",
        "deviceId" : "D74B43ECFCFD",
        "logging" : "standard"
      }
    ],
    "irdevices" : [

    ]
  },
  "platform" : "SwitchBot"
}

Screenshots

No response

Device & Model

Blind Tilts. Homebridge running on Docker on Intel NUC.

Node.js Version

v18.13.0

NPM Version

v

Homebridge Version

v1.6.0

Homebridge Switchbot Plugin Version

v2.5.1

Homebridge Config UI X Plugin Version

v4.50.2

Operating System

Unraid

@donavanbecker
Copy link
Collaborator

Any thoughts @AndreasVerhoeven?

@AndreasVerhoeven
Copy link

I think this was fixed in 2.5.2-beta

@donavanbecker
Copy link
Collaborator

Thanks @AndreasVerhoeven!

@donavanbecker
Copy link
Collaborator

@The-Croz can you install the latest beta and see if that works for you?

@The-Croz
Copy link
Author

The-Croz commented Feb 2, 2023

@AndreasVerhoeven @donavanbecker On 2.5.2-beta 1 my blinds will open fine but will not close. When the close command is sent they just get stuck on closing and never move. Any ideas?

@The-Croz
Copy link
Author

The-Croz commented Feb 2, 2023

@AndreasVerhoeven @donavanbecker Here's some debug logs of when they are attempted to be closed from the open position. When HK is stuck on "closing" one of those chunks of messages will come through every two seconds in debug logging mode until they are toggled again to set them back to "open".

[2/1/2023, 9:35:02 PM] [SwitchBot] [DEBUG] Blind Tilt: Playroom Side Blinds Sending request to SwitchBot API, body: {"command":"setPosition","parameter":"down;0","commandType":"command"},
[2/1/2023, 9:35:02 PM] [SwitchBot] [DEBUG] Blind Tilt: Playroom Side Blinds openAPIpushChanges: {"_events":{"response":[Function],"error":[Function]},"_eventsCount":2,"_maxListeners":[Undefined],"outputData":[{"data":"POST /v1.1/devices/D74B43ECFCFD/commands HTTP/1.1\r\nAuthorization: d513c1eb3109e60ab61b25bb4f03f4d8246fd2f3c170515a8013e801ea116d78bc3879fc8ff85767e8d4c10875d939f5\r\nsign: JipL1PrmkAA5GUX5wWyv36W5u/q4ATel0saWt0CnCcI=\r\nnonce: requestID\r\nt: 1675305302681\r\nContent-Type: application/json\r\nContent-Length: 70\r\nHost: api.switch-bot.com\r\nConnection: close\r\n\r\n{\"command\":\"setPosition\",\"parameter\":\"down;0\",\"commandType\":\"command\"}","encoding":[Undefined],"callback":[Function]},{"data":"","encoding":"latin1","callback":[Function]}],"outputSize":421,"writable":true,"destroyed":false,"_last":true,"chunkedEncoding":false,"shouldKeepAlive":false,"maxRequestsOnConnectionReached":false,"_defaultKeepAlive":true,"useChunkedEncodingByDefault":true,"sendDate":false,"_removedConnection":false,"_removedContLen":false,"_removedTE":false,"strictContentLength":false,"_contentLength":70,"_hasBody":true,"_trailer":"","finished":true,"_headerSent":true,"_closed":false,"socket":null,"_header":"POST /v1.1/devices/D74B43ECFCFD/commands HTTP/1.1\r\nAuthorization: d513c1eb3109e60ab61b25bb4f03f4d8246fd2f3c170515a8013e801ea116d78bc3879fc8ff85767e8d4c10875d939f5\r\nsign: JipL1PrmkAA5GUX5wWyv36W5u/q4ATel0saWt0CnCcI=\r\nnonce: requestID\r\nt: 1675305302681\r\nContent-Type: application/json\r\nContent-Length: 70\r\nHost: api.switch-bot.com\r\nConnection: close\r\n\r\n","_keepAliveTimeout":0,"_onPendingData":[ReferenceTo this.outputData[0].callback],"agent":{"_events":{"free":[Function],"newListener":[Function]},"_eventsCount":2,"_maxListeners":[Undefined],"defaultPort":443,"protocol":"https:","options":{"noDelay":true,"path":null},"requests":{},"sockets":{"api.switch-bot.com:443:::::::::::::::::::::":[{"_tlsOptions":{"allowHalfOpen":[Undefined],"pipe":false,"secureContext":{"context":{}},"isServer":false,"requestCert":true,"rejectUnauthorized":true,"session":[Undefined],"ALPNProtocols":[Undefined],"requestOCSP":[Undefined],"enableTrace":[Undefined],"pskCallback":[Undefined],"highWaterMark":[Undefined],"onread":[Undefined],"signal":[Undefined]},"_secureEstablished":false,"_securePending":false,"_newSessionPending":false,"_controlReleased":true,"secureConnecting":true,"_SNICallback":null,"servername":null,"alpnProtocol":null,"authorized":false,"authorizationError":null,"encrypted":true,"_events":{"close":[[Function],[Function],[Function]],"end":[[Function],[Function]],"newListener":[Function],"connect":[Function],"secure":[Function],"session":[Function],"free":[Function],"timeout":[Function],"agentRemove":[Function]},"_eventsCount":9,"connecting":true,"_hadError":false,"_parent":null,"_host":"api.switch-bot.com","_closeAfterHandlingError":false,"_readableState":{"objectMode":false,"highWaterMark":16384,"buffer":{"head":null,"tail":null,"length":0},"length":0,"pipes":[],"flowing":null,"ended":false,"endEmitted":false,"reading":false,"constructed":true,"sync":true,"needReadable":false,"emittedReadable":false,"readableListening":false,"resumeScheduled":false,"errorEmitted":false,"emitClose":false,"autoDestroy":true,"destroyed":false,"errored":null,"closed":false,"closeEmitted":false,"defaultEncoding":"utf8","awaitDrainWriters":null,"multiAwaitDrain":false,"readingMore":false,"dataEmitted":false,"decoder":null,"encoding":null},"_maxListeners":[Undefined],"_writableState":{"objectMode":false,"highWaterMark":16384,"finalCalled":false,"needDrain":false,"ending":false,"ended":false,"finished":false,"destroyed":false,"decodeStrings":false,"defaultEncoding":"utf8","length":0,"writing":false,"corked":0,"sync":true,"bufferProcessing":false,"onwrite":[Function],"writecb":null,"writelen":0,"afterWriteTickInfo":null,"buffered":[],"bufferedIndex":0,"allBuffers":true,"allNoop":true,"pendingcb":0,"constructed":true,"prefinished":false,"errorEmitted":false,"emitClose":false,"autoDestroy":true,"errored":null,"closed":false,"closeEmitted":false},"allowHalfOpen":false,"_sockname":null,"_pendingData":null,"_pendingEncoding":"","server":[Undefined],"_server":null,"ssl":{"_parent":{"reading":false,"onconnection":null},"_parentWrap":[Undefined],"_secureContext":[ReferenceTo this.agent.sockets.api.switch-bot.com:443:::::::::::::::::::::[0]._tlsOptions.secureContext],"reading":false,"onkeylog":[Function],"onhandshakestart":[Function],"onhandshakedone":[Function],"onocspresponse":[Function],"onnewsession":[Function],"onerror":[Function]},"_requestCert":true,"_rejectUnauthorized":true}]},"freeSockets":{},"keepAliveMsecs":1000,"keepAlive":false,"maxSockets":null,"maxFreeSockets":256,"scheduling":"lifo","maxTotalSockets":null,"totalSocketCount":1,"maxCachedSessions":100,"_sessionCache":{"map":{},"list":[]}},"socketPath":[Undefined],"method":"POST","maxHeaderSize":[Undefined],"insecureHTTPParser":[Undefined],"path":"/v1.1/devices/D74B43ECFCFD/commands","_ended":false,"res":null,"aborted":false,"timeoutCb":null,"upgradeOrConnect":false,"parser":null,"maxHeadersCount":null,"reusedSocket":false,"host":"api.switch-bot.com","protocol":"https:"}
[2/1/2023, 9:35:03 PM] [SwitchBot] [DEBUG] Blind Tilt: Playroom Side Blinds openAPIpushChanges statusCode: 200
[2/1/2023, 9:35:03 PM] [SwitchBot] [DEBUG] Blind Tilt: Playroom Side Blinds Unknown statusCode.
[2/1/2023, 9:35:03 PM] [SwitchBot] [DEBUG] Blind Tilt: Playroom Side Blinds d: {"statusCode":400,"body":{},"message":"ExpressionAttributeValues contains invalid value: The parameter cannot be converted to a numeric value: NaN for key :dataItem"}
[2/1/2023, 9:35:03 PM] [SwitchBot] [DEBUG] Blind Tilt: Playroom Side Blinds Refresh Status When Moving, PositionState: 0
[2/1/2023, 9:35:03 PM] [SwitchBot] [DEBUG] Blind Tilt: Playroom Side Blinds openAPIRefreshStatus
[2/1/2023, 9:35:03 PM] [SwitchBot] [DEBUG] Blind Tilt: Playroom Side Blinds sign: uFTjIGwlU9PFxE/zAzaLDav+dzUaHksNknOQIwieU0E=
[2/1/2023, 9:35:03 PM] [SwitchBot] [DEBUG] Blind Tilt: Playroom Side Blinds statusCode: 200
[2/1/2023, 9:35:03 PM] [SwitchBot] [DEBUG] Blind Tilt: Playroom Side Blinds d: {"statusCode":100,"body":{"deviceId":"D74B43ECFCFD","deviceType":"Blind Tilt","hubDeviceId":"F266795A3C9A","version":20,"calibrate":true,"battery":100,"direction":"Down","slidePosition":50},"message":"success"}
[2/1/2023, 9:35:03 PM] [SwitchBot] [DEBUG] Blind Tilt: Playroom Side Blinds refreshStatus: {"statusCode":100,"body":{"deviceId":"D74B43ECFCFD","deviceType":"Blind Tilt","hubDeviceId":"F266795A3C9A","version":20,"calibrate":true,"battery":100,"direction":"Down","slidePosition":50},"message":"success"}
[2/1/2023, 9:35:03 PM] [SwitchBot] [DEBUG] Blind Tilt: Playroom Side Blinds openAPIparseStatus
[2/1/2023, 9:35:03 PM] [SwitchBot] [DEBUG]  device: 50 => HK: 100
[2/1/2023, 9:35:03 PM] [SwitchBot] [DEBUG] Blind Tilt: Playroom Side Blinds CurrentPosition: 100
[2/1/2023, 9:35:03 PM] [SwitchBot] Blind Tilt: Playroom Side Blinds Checking Status ...
[2/1/2023, 9:35:03 PM] [SwitchBot] [DEBUG] runStatus: undefined
[2/1/2023, 9:35:03 PM] [SwitchBot] [DEBUG] Blind Tilt: Playroom Side Blinds updateCharacteristic CurrentPosition: 100
[2/1/2023, 9:35:03 PM] [SwitchBot] [DEBUG] Blind Tilt: Playroom Side Blinds updateCharacteristic PositionState: 0
[2/1/2023, 9:35:03 PM] [SwitchBot] [DEBUG] Blind Tilt: Playroom Side Blinds updateCharacteristic TargetPosition: 0
[2/1/2023, 9:35:03 PM] [SwitchBot] [DEBUG] Blind Tilt: Playroom Side Blinds updateCharacteristic CurrentAmbientLightLevel: 6001
[2/1/2023, 9:35:03 PM] [SwitchBot] [DEBUG] Blind Tilt: Playroom Side Blinds Opening, CurrentPosition: 100 
[2/1/2023, 9:35:03 PM] [SwitchBot] [DEBUG] Blind Tilt: 100 DECREASING PositionState: 0
[2/1/2023, 9:35:03 PM] [SwitchBot] [DEBUG] Blind Tilt: Playroom Side Blinds CurrentPosition: 100, TargetPosition: 0, PositionState: 0,
[2/1/2023, 9:35:03 PM] [SwitchBot] [DEBUG] Blind Tilt: Playroom Side Blinds CurrentAmbientLightLevel: 6001
[2/1/2023, 9:35:04 PM] [SwitchBot] [DEBUG] Blind Tilt: Playroom Side Blinds setNewTarget true timeout
[2/1/2023, 9:35:04 PM] [SwitchBot] [DEBUG] Blind Tilt: Playroom Side Blinds No Changes, Set TargetPosition: 100
[2/1/2023, 9:35:04 PM] [SwitchBot] [DEBUG] setMinMax
[2/1/2023, 9:35:04 PM] [SwitchBot] [DEBUG] Blind Tilt: Playroom Side Blinds value: 100, CurrentPosition: 100
[2/1/2023, 9:35:04 PM] [SwitchBot] [DEBUG] Blind Tilt: Playroom Side Blinds updateRate: 2
[2/1/2023, 9:35:04 PM] [SwitchBot] [DEBUG] Blind Tilt: Playroom Side Blinds OpenAPI pushChanges
[2/1/2023, 9:35:04 PM] [SwitchBot] [DEBUG] Blind Tilt: Playroom Side Blinds No OpenAPI Changes, CurrentPosition & TargetPosition Are the Same. CurrentPosition: 100, TargetPosition  100
[2/1/2023, 9:35:17 PM] [SwitchBot] [DEBUG] Blind Tilt: Playroom Side Blinds openAPIRefreshStatus
[2/1/2023, 9:35:17 PM] [SwitchBot] [DEBUG] Blind Tilt: Playroom Side Blinds sign: NHyajI2anRGiKHDVs3X+3RiYez3HiAR6MUee1EjbFK4=
[2/1/2023, 9:35:18 PM] [SwitchBot] [DEBUG] Blind Tilt: Playroom Side Blinds statusCode: 200
[2/1/2023, 9:35:18 PM] [SwitchBot] [DEBUG] Blind Tilt: Playroom Side Blinds d: {"statusCode":100,"body":{"deviceId":"D74B43ECFCFD","deviceType":"Blind Tilt","hubDeviceId":"F266795A3C9A","version":20,"calibrate":true,"battery":100,"direction":"Down","slidePosition":50},"message":"success"}
[2/1/2023, 9:35:18 PM] [SwitchBot] [DEBUG] Blind Tilt: Playroom Side Blinds refreshStatus: {"statusCode":100,"body":{"deviceId":"D74B43ECFCFD","deviceType":"Blind Tilt","hubDeviceId":"F266795A3C9A","version":20,"calibrate":true,"battery":100,"direction":"Down","slidePosition":50},"message":"success"}
[2/1/2023, 9:35:18 PM] [SwitchBot] [DEBUG] Blind Tilt: Playroom Side Blinds openAPIparseStatus
[2/1/2023, 9:35:18 PM] [SwitchBot] [DEBUG]  device: 50 => HK: 100
[2/1/2023, 9:35:18 PM] [SwitchBot] [DEBUG] Blind Tilt: Playroom Side Blinds CurrentPosition: 100
[2/1/2023, 9:35:18 PM] [SwitchBot] [DEBUG] runStatus: undefined
[2/1/2023, 9:35:18 PM] [SwitchBot] [DEBUG] Blind Tilt: Playroom Side Blinds updateCharacteristic CurrentPosition: 100
[2/1/2023, 9:35:18 PM] [SwitchBot] [DEBUG] Blind Tilt: Playroom Side Blinds updateCharacteristic PositionState: 2
[2/1/2023, 9:35:18 PM] [SwitchBot] [DEBUG] Blind Tilt: Playroom Side Blinds updateCharacteristic TargetPosition: 100
[2/1/2023, 9:35:18 PM] [SwitchBot] [DEBUG] Blind Tilt: Playroom Side Blinds updateCharacteristic CurrentAmbientLightLevel: 6001
[2/1/2023, 9:35:18 PM] [SwitchBot] [DEBUG] Blind Tilt: 100 Standby because reached position, CurrentPosition: 100
[2/1/2023, 9:35:18 PM] [SwitchBot] [DEBUG] Blind Tilt: 100 STOPPED PositionState: 2
[2/1/2023, 9:35:18 PM] [SwitchBot] [DEBUG] Blind Tilt: Playroom Side Blinds CurrentPosition: 100, TargetPosition: 100, PositionState: 2,
[2/1/2023, 9:35:18 PM] [SwitchBot] [DEBUG] Blind Tilt: Playroom Side Blinds CurrentAmbientLightLevel: 6001
[2/1/2023, 9:35:19 PM] [SwitchBot] [DEBUG] Blind Tilt: Playroom Side Blinds openAPIRefreshStatus
[2/1/2023, 9:35:19 PM] [SwitchBot] [DEBUG] Blind Tilt: Playroom Side Blinds sign: tPXOZk9fgizjbA+7XWNLI1rbUp9qVXhYhX0FQ3BPXdk=

@AndreasVerhoeven
Copy link

’d: {"statusCode":400,"body":{},"message":"ExpressionAttributeValues contains invalid value: The parameter cannot be converted to a numeric value: NaN for key :dataItem"}'

This is an issue at the switchbot API unfortunately. We have to work around it I think.

@The-Croz
Copy link
Author

The-Croz commented Feb 4, 2023

Bummer. Well keep me posted if there's anything I can help test. Thanks for working on this @AndreasVerhoeven

@donavanbecker donavanbecker added pinned OpenAPI Issue dealing with OpenAPI (SwitchBotAPI) labels Feb 4, 2023
@AndreasVerhoeven
Copy link

Bummer. Well keep me posted if there's anything I can help test. Thanks for working on this @AndreasVerhoeven

I worked around this in #672 . Unfortunately, due to the various bugs in Switchbot's API, the home app might not always reflect the actual value of the device. Let's hope Switchbot fixes their API

@donavanbecker donavanbecker changed the title Blind Tilts won't change mapping modes based on mode changes in Homebridge Bug: Blind Tilts won't change mapping modes based on mode changes in Homebridge Jul 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working OpenAPI Issue dealing with OpenAPI (SwitchBotAPI)
Projects
None yet
Development

No branches or pull requests

8 participants