hbblebc / homebridge-bed-control

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

Foundation is discovered even if no foundation is present. #2

Closed traviswparker closed 2 years ago

traviswparker commented 2 years ago

Is your feature request related to a problem? Please describe:

snapi.getFoundationStatus does not return undefined if foundationStatus request fails, which causes bed setup in platform.ts to not throw an exception and set foundation to true. This adds useless controls to Home and throws errors in the HB logs.

Describe the solution you'd like:

removing the if (res !== undefined) { condition that was added to snapi.foundationStatus in 1.2.0 fixes it for now, but you can check the base: value in the bedStatus result for the foundation. It will be non-null if a foundation is present.

Describe alternatives you've considered:

Additional context:

hbblebc commented 2 years ago

That’s interesting. I have two beds - one with a foundation and one without. My bed without a foundation configured correctly. I know the foundation API is kind of weird across different bed versions though. What model of bed do you have and roughly when did you buy it?

Regardless, I will add better checks at that part of the setup to make sure it works properly.

hbblebc commented 2 years ago

Can you tell me what the API request does return in your case?

traviswparker commented 2 years ago

You wouldn’t see if if your beds were cached before 1.2.0 as it occurs during new device setup. I reset HB to clean up unrelated stuff and ran into this bug. I can dig into API responses tomorrow.

hbblebc commented 2 years ago

Okay thanks, I will see if I can reproduce it as well.

traviswparker commented 2 years ago

From what I've seen in other projects, if no foundation it should be a 404.