Snoo Smart Sleeper custom component

This is a custom component to monitor a Snoo Smart Sleeper bassinet. It adds a sensor showing the current status of the Snoo: one of Awake (Snoo is inactive), Asleep, or Soothing. And, if soothing, the current soothing level.

This uses the undocumented Happy Baby API. Controlling the device isn’t possible, as that uses a different mechanism. It doesn’t yet deal with the “Action Stopped” state, as I haven’t tried to upset my baby enough to find out how it is reported by the API. :slight_smile:

https://bitbucket.org/pjhardy/homeassistant-snoo/src/master/

1 Like

Any opportunity here to send commands to the Snoo?
-start/stop
-increase/decrease motion level
-set preferences / default motion levels
-enable/disable motion limiter

Note that it is only possible to read the current status. Sending commands is not supported, and won’t be in the forseeable future.

The web API is read-only. The Snoo uses PubNub to send commands. If you’d like to contribute, there’s been a little conversation in the related github issue about it: PubNub API support? · Issue #3 · maebert/snoo · GitHub

Thanks for sharing, this is great. I just got it set up and will be using it to trigger light automations.

Thank you for your work in putting this together, certainly a niche integration but I’m excited to add it.

I followed the instructions in the ReadMe, I get to this screen and it does nothing when I try to log in: image

Any idea what is going on? Thanks!

Top one is for username, bottom is for password, both for the snoo account

That’s what I assumed, I put in the credentials I use in the app which I assume are the same as my “Happiest Baby account” from the ReadMe. When I click submit, the fields clear and nothing happens. No sensors are created.

it probably did work… the device does not show any entities, but one called sensor.snoo_state should be created

and of course by device i meant integration, the code functions quite well, but the implementation is incomplete, I may try to improve it.

The big thing is that if the snoo times out at level 4, the status of the sensor changes to “None”

You’re saying there should be no device but there should be an entity? When I search my entities for snoo I don’t get any results:

Thank you for helping :slight_smile:

I did find this in my logs:
2020-12-20 05:41:37 ERROR (MainThread) [custom_components.snoo.config_flow] Unexpected exception

Traceback (most recent call last):

File "/config/custom_components/snoo/config_flow.py", line 52, in async_step_user

info = await validate_input(self.hass, user_input)

File "/config/custom_components/snoo/config_flow.py", line 36, in validate_input

result = await hass.async_add_executor_job(

File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run

result = self.fn(*self.args, **self.kwargs)

File "/config/custom_components/snoo/config_flow.py", line 22, in fetch_token

client.auth["password"] = password

File "/usr/local/lib/python3.8/configparser.py", line 1259, in __setitem__

return self._parser.set(self._name, key, value)

File "/usr/local/lib/python3.8/configparser.py", line 1201, in set

super().set(section, option, value)

File "/usr/local/lib/python3.8/configparser.py", line 894, in set

value = self._interpolation.before_set(self, section, option,

File "/usr/local/lib/python3.8/configparser.py", line 402, in before_set

raise ValueError("invalid interpolation syntax in %r at "

ValueError: invalid interpolation syntax in '{My Password in plain text}' at position 1

Aha! I had some symbols in my password that may have messed up how the script was storing the variable or something? I removed the symbols from my password and just did letters and numbers and it worked like a charm!

Yes, there is an issue with python where some password input containing things like % cause input to fail or something… cant remember

1 Like

Yeah, there was a % in there, that is what I suspected.

Please do, with my blessing. I got a lot of use out of it, but sold my snoo six months ago, and don’t really have the time or urgency to continue maintaining this code.

I uploaded some logo images to the integration image repository, they are already loading for me on my phone, but not on my pc, at some point they should magically appear for everyone’s integration

Has there been any updates to this? I don’t see any forks on gitlab.

I just tried this and the state isn’t changing with this present in my logs:

Logger: homeassistant.helpers.entity
Source: custom_components/snoo/sensor.py:63
First occurred: February 28, 2021, 11:55:07 AM (3121 occurrences)
Last logged: 1:57:14 PM

Update for sensor.snoo_state fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 278, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 474, in async_device_update
    raise exc
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/snoo/sensor.py", line 63, in update
    session = self._client.get_current_session()
  File "/usr/local/lib/python3.8/site-packages/snoo/client.py", line 274, in get_current_session
    level = data["levels"][-1]["level"]
IndexError: list index out of range

Sorry for the dumb question, but I have followed the instructions and I am not sure how to install the integration.

  • I copied the code to custom_components
  • I restarted Home Assistant

And the next step is to “Create a new integration through the Home Assistant UI”. What is the name of this new integration? I have searched for Snoo, Happiest Baby and every name I could think of.

I also looked in my logs and I see:

2021-05-29 15:24:38 WARNING (MainThread) [homeassistant.loader] You are using a custom integration snoo which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant

So I am pretty sure I have it correctly copied, but maybe I am missing something?

The name of the integration is indeed Happiest Baby Snoo Smart Bassinet, but just typing snoo into the integration search should pull it up