My bed has an API, so obviously I want to integrate it into homeassistant SleepNumber beds have an addon called SleepIQ. It tracks sleep over time, and in particular, it does know if you are in bed or not, and it knows your āSleepNumberā (firmness of the mattress). There are controls for changing the incline of the frame, and firmness, but it requires using bluetooth near the bed, and doesnāt seem to be exposed by the API (I wrote the library sleepyq for interacting it, and made some notes: https://github.com/technicalpickles/sleepyq).
This is my first component, and first real python, so I was hoping to get some feedback before preparing to contribute it.
Hereās the code (place in ~/.homeassistant/customcomponents/sensors/sleepiq.py): https://gist.github.com/technicalpickles/e642164926f4259aa029409f59b0baa3
And a screenshot:
I have a couple questions in particular:
The āis in bedā sensor is at some point a boolean value in a JSON response coming back. It gets represented as True or False in Python, and it seems that setting that as a sensor value renders it as a string āTrueā or āFalseā. Are there any conventions for this? My Ecobee3 occupancy sensors uses ātrueā and āfalseā. The current name of the sensor would suggest āyesā or ānoā as more logical.
I went with making it a sensor, rather than a platform so the config is like:
sensor:
platform: sleepiq
login: whatever
password: whatever
I was thinking itād be a little clearer to make it a platform, so itād be like:
sleepiq:
login: whatever
password: whatever
Is there a convention for when to use a platform vs the type of component (ie sensor)? Some part of me hopes they release more API functionality, so I can make a bed domain, and that would justify a platform I think.