dgreif / homebridge-hatch-baby-rest

A homebridge plugin for Hatch Baby Rest night light
MIT License
74 stars 19 forks source link

Using as a sleep/wake light #38

Closed Jud closed 3 years ago

Jud commented 3 years ago

We use our Rest lights in a sleep/wake configuration where the light is red + sound during the night, and green w/ no sound in the morning when it is time to wake.

I've attempted to set this up via configuring the light as two accessories but I'm not sure the plugin is handling this well. In the logs, when I attempt to turn on the 'wake' accessory for instance, I see entries for connecting to both the 'sleep' and 'wake' accessory. I'd guess because they share a mac address.

Curious if there is a supported method for using this plugin with a sleep/wake type configuration? If not, I may try and hack it in myself if you would be interested.

dgreif commented 3 years ago

You are correct that sleep/wake isn't really supported at the moment. The hard part is that HomeKit doesn't expose a good control for things like selecting from a list of sounds. I could expose the volume via a speaker, but you would have to use a third-party HomeKit app to control it because the standard Home app doesn't allow you to interact with speakers. Is your wake schedule completely based on time of day, or other triggers? If it's just based on time, I recommend using the official Rest app to set up that automation

Jud commented 3 years ago

For my case, I think the ability to setup two configurations (accessories) for the same device mac address would be sufficient. Our nightly sleep/wake is automated with a simple schedule, but the nap schedule shifts around enough that we're usually just fumbling with the app to get both boys up at the same time. Ideally, I'd be able to create a shortcut for "Siri, wake up the boys" and it turns both wake accessories on.

Should setting up two accessories, a "sleep" and "wake" accessory for the same rest device, work? When I initially tested, it didn't work and I assumed it was mac address being used as a hash key or something so didn't try debugging very thoroughly -- but after a cursory look at the code, I don't see an obvious reason my two accessory config wouldn't work (thought, not familiar at all w/ homebridge plugin architecture).

Also, thanks for creating this plugin! In the worst case, I think I could create only the 'wake' accessory and simply tap device before bed/nap to turn on the sleep light/sound via a 'Favorite'. It's great to be able to add these devices to homekit and get everything under a single app umbrella.

dgreif commented 3 years ago

You should be able to add 2 accessories with the sam mac. The issue is that the bluetooth can be a bit touchy, especially if you are on a raspberry pi. I'd try that approach again and if it doesn't work, then may use programmed timers (in the hatch sleep app) for the sleep routine and homebridge for the wake routine.

arvathrowaway commented 3 years ago

The issue is that the bluetooth can be a bit touchy, especially if you are on a raspberry pi.

Commenting to confirm that is indeed the case on a RPi Zero W. Multiple devices seem to be connecting and command seem to be getting sent but nothing happens on the device. Simple took it down to one device, and it works fine.

timwitty commented 3 years ago

Can you clarify why this would be a bluetooth issue and not a plugin or homebridge issue? I can confirm having only one accessory works. So, something is definitely wrong with multiple accessories to a single device. I just think its odd the potential root cause being discussed is bluetooth.

If I'm hitting the on/off for a single accessory to set a particular configuration on the Rest, I would expect only a single connection and configuration sent to the device. Even if it sent all of them, I would expect one to win out.

When I have multiple accessories for a single device I get the below in the logs. Only a single connection message for the accessory I actually turned on. But, disconnections for all of them.

I'm new to homebridge development, is there are recommended place to perhaps get a quick answer on this one from their side on who this type of configuration should work in theory?

[1/8/2021, 8:02:18 PM] [Nursery  Rest - Routine] Turning on
[1/8/2021, 8:02:18 PM] [Nursery  Rest - Routine] Connecting to Rest...
[1/8/2021, 8:02:18 PM] [Nursery  Rest - Routine] Connected to Rest
[1/8/2021, 8:02:23 PM] [Nursery Rest - Sleep] Disconnected from Rest
[1/8/2021, 8:02:23 PM] [Nursery Rest - Wake] Disconnected from Rest
[1/8/2021, 8:02:23 PM] [Nursery  Rest - Routine] Disconnected from Rest
dgreif commented 3 years ago

@Jud v3.0.0 of the plugin will give you access to control color and sound from the Home app. See https://github.com/dgreif/homebridge-hatch-baby-rest/wiki/Upgrading-from-v2-to-v3 for details about the recent changes. This should eliminate the need for two separate lights in your config. When you update, the duplicate lights will automatically be removed from your config.

Jud commented 3 years ago

Thanks @dgreif!

dgreif commented 3 years ago

@Jud if the update is working well for your needs, feel free to close this issue.