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
Add Eight sleep component #7275
Conversation
return self._state | ||
|
||
@property | ||
def state(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this. This is taken care of by the BinarySensor entity.
async_add_devices(all_sensors, True) | ||
|
||
|
||
class EightHeatSensor(EightSleepHeatEntity): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to always also inherit from the component abstract bcase class that you're a platform a for, in this case BinarySensorDevice
return STATE_ON if self.is_on else STATE_OFF | ||
|
||
@property | ||
def unit_of_measurement(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this and it will default to None.
hass.data[DATA_EIGHT] = eight | ||
|
||
# Authenticate, build sensors | ||
yield from eight.start() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to validate that the auth is correct here and return False
if it's incorrect ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I'll add it into the library and update accordingly.
|
||
if 'current' in self._sensor_root: | ||
state_attr[ATTR_RESP_RATE] = round(self._attr['resp_rate'], 2) | ||
state_attr[ATTR_HEART_RATE] = round(self._attr['heart_rate'], 2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it make more sense for a lot of these things to be separate sensors?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can go that route if you think it makes more sense. My intention was to make the data available and let the user template out whichever values they were interested in since they are only updated when a sleep session is active. Right now we're at 8 total sensors for both left/right sides of the bed, if I split out the active session values we'd be adding another 10. It just seemed like data overload to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, that is a lot of entities . But maybe still split out the temperature sensors? Those are always nice to have. Those also don't have to be shared per side of the bed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've broken out the bed temps, room temp, and sleep stage. I think those would be the most useful.
state_attr[ATTR_RESP_RATE] = round(self._attr['resp_rate'], 2) | ||
state_attr[ATTR_HEART_RATE] = round(self._attr['heart_rate'], 2) | ||
state_attr[ATTR_SLEEP_STAGE] = self._attr['stage'] | ||
state_attr[ATTR_ROOM_TEMP] = room_temp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Especially these would be great to break out into their own entities.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beautiful! 🐬
Description:
Implementation of a component to fetch data from Eight Sleep covers and mattresses.
Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.io#2499
Example entry for
configuration.yaml
(if applicable):Checklist:
If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
tox
run successfully. Your PR cannot be merged unless tests passREQUIREMENTS
variable (example).requirements_all.txt
by runningscript/gen_requirements_all.py
..coveragerc
.