lukas-clarke / eight_sleep

Home Assistant Eight Sleep integration that works with Eight Sleep's new API and OAUTH2
MIT License
62 stars 11 forks source link

Remove unnecessary/confusing if statement for determining awake mode. #8

Closed keatontaylor closed 6 months ago

keatontaylor commented 7 months ago

https://github.com/lukas-clarke/eight_sleep/blob/8f0aeb5d4a42f5c053b2efff1fc6a0b89fb8895a/custom_components/eight_sleep/pyEight/user.py#L245C1-L251C27

        # Second try at forcing awake using heating level
        if (
            stage != "awake"
            and self.heating_level is not None
            and self.heating_level < 5
        ):
            return "awake"

The above code seems to ignore what is directly returned by the API and instead this if statement appears to make no sense in terms of its actual logic. Seems to indicate if the heating level is ever < 5 that even if the bed marks you as asleep it will instead mark you as awake. This likely works for those who wish to keep the bed > 5 when in the sleep:intial and sleep:final state, but seems like logic that can be entirely removed and if anyone needs this they can do so via a template in HA directly.

lukas-clarke commented 6 months ago

Addressed in latest release.

keatontaylor commented 6 months ago

Excellent work, wish my eight sleep hadn't sprung a leak yesterday lol