dgreif / homebridge-hatch-baby-rest

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

Rest+ #1

Closed simplytoast1 closed 4 years ago

simplytoast1 commented 4 years ago

Does this also support the Rest+ if I add the WiFi MAC?

dgreif commented 4 years ago

Unfortunately the Rest+ is not currently supported by this homebridge plugin. The original uses bluetooth, while the Rest+ uses wifi. I don't own a Rest+ to test with so I won't be able to implement it. I'm happy to take a PR if someone owns one and has the ability to implement it.

simplytoast1 commented 4 years ago

@dgreif Ping me and lets see what I can do!

dgreif commented 4 years ago

@ddorato I’m glad you are still interested. Are you thinking about developing it yourself, or did you want to donate so that I can buy one and implement it?

simplytoast1 commented 4 years ago

@dgreif The dev skills aren't really there but I can donate. Whats the best way to reach you?

dgreif commented 4 years ago

I have a PayPal link in the Sponsor button on the repo. Looks like they are $90 currently on amazon. If you donate the full amount, I will get one ordered and implement it when I am able. Fair warning up front, there are no guarantees that I can reverse engineer their API (though I do have a fair amount of experience at it), and I can’t make any promises on a time line. Likely looking at some time in the next month or two. If you are not comfortable with any of that, I completely understand. If you are comfortable, I’ll get it ordered as soon as I see the donation come through.

dgreif commented 4 years ago

Order placed, thanks @ddorato! I’ll keep you posted as I make progress on the implementation. Have a happy new year!

dgreif commented 4 years ago

@ddorato I have updates! First off, thank you very much for the light. I had forgotten how many features they packed into the Rest +, but this thing is awesome!

I got a chance to poke around at the requests from the app and was able to figure out how they are interacting with these lights over wifi. They are using the AWS IoT service, which is built on MQTT, to send and receive the state of the light. By observing the messages, it's pretty straightforward to see how they are turning it on, setting light/audio, and even selecting presets. From nodejs, I was able to successfully log in, query their API for devices, connect to AWS IoT, turn the light on/off and select a preset πŸŽ‰ πŸš€

So, next step will be solidifying the code and then getting it accessible in the homebridge plugin. One of the really nice things is by having access to the API, we can now set up the plugin as a platform that will fetch the list of lights, rather than needing to have an accessories entry with a mac address for each light you want to add. The only question that remains is what functionality we want to expose for each light. The easy initial steps are on/off, light brightness, volume level, and battery level (all of which should be straightforward). For color selection, I could expose a color picker via HomeKit, but I'm not sure it's really worth it. Audio track is the really tricky one, because there isn't a good HomeKit control for something with 14 choices 😞. My preference at this point would be to implement the easy items, and then always turn the light on with the first preset so that you can customize your color/audio track from the Hatch app and save the preset from there. Would that suite your needs?

simplytoast1 commented 4 years ago

@dgreif I would agree, exposing and on/off, brightness, volume would be essential.

The color picker would actually be good to have for my use case scenario. Use an automation to have the light turn a color at a specific time (Ex: Time to get up).

I agree with the on/off controlling the first preset only and then via the exposed other elements we can use an automation to create any other scenario is desired.

Ideally A combined accessory would make sense, but not sure how to achieve that with a volume variable.

My two cents. And BTW you are awesome!

dgreif commented 4 years ago

@ddorato released in v1.2.0! See the README for the new config setup (you will need to add a platforms entry).

At this point it will turn the light on/off (restoring the light to previous color/audio settings from the last time it was on). You can adjust the brightness from the Home app, and 3rd party HomeKit apps can control volume. I did not end up using preset 1 at all because it made sense to just turn it back on and leave everything how it was previously.

Regarding color picker, I have not yet implemented it. I may circle back and do it at some point, but don't forget you can still use programmed schedules from the Hatch Baby app if you want it to change colors at a set time for Time-To-Wake. If you wanted to trigger this from other HomeKit sensors, please let me know.

Can't wait to hear back on how it works for you! Thanks again for providing the light, I'm looking forward to automating this thing 😁

simplytoast1 commented 4 years ago

We have success!

I think the logic to return to the previous state made the most sense for a v 1.0 rollout.

Right now I am still going to rely on the Hatch schedule for the color changing at a specific time - but when a color picker gets introduced that would be the ideal (and dream) automation so I can have HK dictate the timer for single app control and tied into other HK device triggers.

But perhaps (Also, since it's funny I use the rainbow for another timed automation in Hatch) is the plugin could expose presets as individual switches in HK to make the programming easier on you.

HammerAce42 commented 4 years ago

So glad to see that Rest+ support has been added - thanks for working on this, @dgreif!

The lack of a color picker/any way to control color unfortunately makes this not very useful, since I wanted to setup an automation for changing color based on the state of other sensors/accessories (and hence can't use the schedule feature in the Hatch app that @ddorato suggested as a work around).

dgreif commented 4 years ago

@ddorato @HammerAce42 I just release v1.3.0 with color picker support for the HBR+ 😁. Converting from RGB to HSB was the tricky part, but I finally got some time to figured out last night. The colors that you select in HomeKit will be converted and may not match perfectly to the end color on the light, but they are really really close. Play around with it and let me know what you think πŸ˜„

dgreif commented 4 years ago

If you guys gave 1.3.0 a try and didn't see any color picker show up, it's because HomeKit was using the cached light and not allowing Hue/Saturation to be added. Removing the cached light is really tricky, so I just deployed 1.3.1 which adds a removeAll option that will clear out all of your Rest+ lights from the platform. This will also remove any automations you have, so make note of those before you set it. Once you have those noted, use the following steps:

  1. Add "removeAll": true to the config block for the hatch platform
  2. Restart your homebridge server. You should see a line that says REMOVING ALL Hatch Baby Rest+ lights.. At this point, your Rest+ lights should disappear on the HomeKit side
  3. Remove the removeAll line from your config
  4. Restart homebridge server again. Now your lights should return, with color wheel added.

Sorry for the extra hassle, but HomeKit is definitely being picky!

HammerAce42 commented 4 years ago

@dgreif, thanks for landing the color picker! It seemed to work for me with 1.3.0 and while I did upgrade to 1.3.1 a short while ago, I didn't go through the steps you outlined since they only seem necessary if the color picker doesn't show up.