d03n3rfr1tz3 / hass-divoom

Divoom Integration for Home Assistant
MIT License
110 stars 9 forks source link

"set sleep auto off" #37

Closed vincentezw closed 5 months ago

vincentezw commented 5 months ago

Thanks so much for your work on this. So far, it's working great. I was missing options for the "sleep" function though, which plays soothing sounds like a river, rain etc. for a set period of time.

This PR adds the two commands "set sleep auto off" and "set sleepscene listen".

The difference between the two, is that "sleep auto off" shows a "sleep light" and switches off after the set timeout.

I have no idea what devices support this, or don't, so I added this in the generic Divoom class. So far so good on my Timebox Evo.

vincentezw commented 5 months ago

Update: I removed set sleepscene listen from the PR. This only plays a sound once. I think the app repeatedly calls this when navigating the different sound options.

The set sleep auto off works well on my Timebox. I did note that in the app, one can choose "standby" or "poweroff" after the time runs out. Whichever you've selected in the app, is what this command does. I'm not sure how we can influence that from the API. The set sleepscene (0x41) command does not work correctly on my device.

I correlated the "sleepmode" option to the following sounds:

1 Music
2 Midnight
3 Seashore
4 Cave
5 Music box
6 Fire
7 Meditation
8 Thunderstorm
9 Nightfall
10 Countryside
11 Creeks
12 wind
13 Relax
14 Birds
15 Frog
16 Lullaby
17 Rain 
18 Underwater
19 Garden
20 white noise?
21 Whisper?
22 Immerse 
23 Crystal
d03n3rfr1tz3 commented 5 months ago

Looks good. Thank you already for your contribution.

I'll test it as soon as I have a bit more time and maybe even add the FM frequency option. Might also be a good idea to also add it to my ESP32 thingy. Regarding the support I would also have to guess. All audio-supported Divoom devices probably have that feature, which basically rules out the original Pixoo, which only has a buzzer.

vincentezw commented 5 months ago

I'm happy to add an input for the FM frequency, if you like. I just wasn't sure what it would do here, or how it would be relevant, which is why I hardcoded it to 0x00.

d03n3rfr1tz3 commented 5 months ago

well I'd probably just reuse the part from the alarm mode for example. I can't actually test it, but it should fit. https://github.com/d03n3rfr1tz3/hass-divoom/blob/244531c35c5662ad3147075c06bed1a572792fd2/custom_components/divoom/devices/divoom.py#L590

vincentezw commented 5 months ago

well I'd probably just reuse the part from the alarm mode for example. I can't actually test it, but it should fit.

https://github.com/d03n3rfr1tz3/hass-divoom/blob/244531c35c5662ad3147075c06bed1a572792fd2/custom_components/divoom/devices/divoom.py#L590

what I meant was: I didn't understand the purpose of the parameter on a mode for playing soothing sounds. I realise only now that falling asleep listening to the radio is a valid use-case too 😄 My unit does not have an FM radio, so I can't tophat this fully. But I abstracted the input parsing from the "alarm" into a shared method so this should be fine.