Snoo Smart Sleeper custom component

Looks like this is no longer working

2021-11-06 17:21:06 ERROR (SyncWorker_0) [homeassistant.loader] The custom integration 'snoo' does not have a version key in the manifest file and was blocked from loading. See https://developers.home-assistant.io/blog/2021/01/29/custom-integration-changes#versions for more details

You can modify the manifest file manually to add a version and it will start working again

I was able to get this working yesterday and just wanted to share how to do it. Once you place the snoo folder into the custom_components folder, edit the manifest.json file by adding ā€œversionā€: ā€œ1.0.0ā€, to it:

{
    "domain": "snoo",
    "name": "Happiest Baby Snoo Smart Bassinet",
    "config_flow": true,
    "documentation": "https://bitbucket.org/pjhardy/homeassistant-snoo",
    "requirements": [
        "snoo==0.3.0"
    ],
    "version": "1.0.0",
    "ssdp": [],
    "zeroconf": [],
    "homekit": {},
    "dependencies": [],
    "codeowners": [
        "@pjhardy"
    ]
}

Then restart home assistant and go to Settings ā†’ Devices and Services ā†’ Add Integration and search for ā€œHappiest Baby.ā€ If it doesnā€™t show up, try refreshing the page. Once you have it added, it will prompt for a username and password but the two fields will appear blank. Username goes first, password goes second.

are you getting the ā€œlevelā€ attribute?

Iā€™ve updated my instance to include version but now Iā€™m only getting the state where as before I also got attributes.

Cannot login with a fresh install.
Added instance as suggested and get to the login page, but no success in logging in.

Any suggestions or is there additional requirements other than the custom integration folder?
Thanks

This error originated from a custom integration.

Logger: custom_components.snoo.config_flow
Source: custom_components/snoo/config_flow.py:22
Integration: Happiest Baby Snoo Smart Bassinet (documentation)
First occurred: 22:50:24 (7 occurrences)
Last logged: 23:07:17

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.10/concurrent/futures/thread.py", line 58, 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.10/configparser.py", line 1263, in __setitem__
    return self._parser.set(self._name, key, value)
  File "/usr/local/lib/python3.10/configparser.py", line 1205, in set
    super().set(section, option, value)
  File "/usr/local/lib/python3.10/configparser.py", line 895, in set
    value = self._interpolation.before_set(self, section, option,
  File "/usr/local/lib/python3.10/configparser.py", line 402, in before_set
    raise ValueError("invalid interpolation syntax in %r at "
ValueError: invalid interpolation syntax in '6MaN5dxxxxxxcjSW8%dk' at position 17

Any current snoo users out there?

I have this setup enough that you can add it to HACS as a custom repo GitHub - SgtBatten/ha-snoo: A custom repository for Happiest baby Snoo

image

It only gives me 3 entities though and no control functionality despite using the pubnub api which does have control functionality. Curious if anyone has more working currently?

Iā€™m a current Snoo user, but have just started looking at this integration recently.

Last I had checked the pubnub API still didnā€™t allow control functionality, where are you seeing that it does?

The pubnub api itself seems to, but the integration doesnā€™t utilise everything. It needs some work and iā€™m eager to do it, but have little experience with python.

I have updated both the snoo API and HA plugin to work with the latest changes made by snoo, still a work in progress:

https://github.com/DanPatten/ha-snoo

Thanks, do I have to install your pysnoo any way to make it work? I tried just doing your integration through Hacs but get an error when trying to add my snoo as a device. ā€œConfig flow could not be loadedā€

Try again GitHub - DanPatten/ha-snoo

I fixed a dependency import yesterday

Great, I can confirm it now works! Did you setup any automations or usage tracking?

It could be interesting to have it save some of the data .

This was working for me a few times but it seems the integration needs to be reloaded after a little bit in order to pick up state changes with the snoo. Any idea what that could be?

Im having the same issue now. Still in testing as baby has not arrived yet, so wonder if updating will be more reliable when using more frequently.

Iā€™m trying to use mine every day with the baby to log itā€™s usage and notifications, and it requires a reload before each use. So itā€™s defintely timing out somehwere.

Probably this:

Logger: pysnoo2.oauth2_session
Source: runner.py:188
First occurred: April 6, 2024 at 7:54:42 PM
(1314524 occurrences)
Last logged: 1:00:47 PM

Token expired, getting new token

Yeah, logs show that the token expires 3 hours after login. I donā€™t see a way to refresh the token manually without reloading the integration. Not sure if @w00tadude has a way to do that via pysnoo2.

I think that the nature of Snoo usage means that the integration support is spottyā€”enterprising dev parents try to get the thing running and then (reasonably) abandon the project once their kid outgrows the Snoo. Iā€™ve been poking around the various options and thought Iā€™d share the current state of affairs, in the hopes that it will save future users some time.

TLDR: I think the best option right now is @droansā€™s scripts. Youā€™ll have to first install pyscript via HACS.

The options Iā€™ve tested:

  • @droansā€™s scripts (shared in this issue in the sanghviharshit repo)
    • Pros:
      • Only option that allows you to control the Snoo, as far as I know.
      • Reliable
    • Cons:
      • Most involved installation (but really not so bad). In short, you have to retrieve your serial number (though I think you could just get it from the app instead), install Pyscript, drop in the script, manually replace the email/passwords, and add some template entities.
      • Only fetches Snoo status at set intervals (default is every 5m, which is fine.)
  • DanPatten/ha-snoo repo
    • Pros:
      • Gets Snoo status immediately
      • Easy setup
    • Cons:
      • As just posted here, the token expires after a few hours. You can get around this by writing an automation to call homeassistant.reload_config_entry every 2 hours, but itā€™s a bit of a pain and causes a break in the state of the entities.
      • Can only read, not control the Snoo.
      • Dev @thedan is kindly merging PRs from me and @w00tadude but is, I think, otherwise not actively developing or using the Snoo.
  • sanghviharshit/ha-snoo repo
    • Broken, as far as I can tell. Hasnā€™t had a commit in years.

So at the moment, I would say go with the @droans scripts. I would supplement it with these template sensors, which will allow you to track the length of the current sleep session and look back at the session history.

template:
  - binary_sensor:
      - name: "Snoo active"
        unique_id: snoo_active
        state: "{{ states('sensor.snoo_status') not in ['ONLINE', 'TIMEOUT'] }}"
        availability: "{{ states('sensor.snoo_status') not in ['unknown', 'unavailable', 'none'] }}"
  - sensor:
      - name: "Time in current Snoo session (h)"
        unique_id: hours_in_snoo_session
        state: >-
                {% set secs = 0 if states('binary_sensor.snoo_active')=='off' else now().timestamp() - states.binary_sensor.snoo_active.last_changed.timestamp() %}
                {{ secs / 60 / 60 }}
        unit_of_measurement: h
        device_class: duration
        state_class: measurement
        availability: "{{ states('sensor.snoo_status') not in ['unknown', 'unavailable', 'none'] }}"
2 Likes