[Alpha] Moodo box driver

  • Updates: 22-Mar-2021 Polling enhancements

Info

The Moodo box is a smart home diffuser (http://moodo.co)

I got fed up with bouncing control of my Moodo boxes off IFTTT and couldn't find a Hubitat driver for them so I wrote one. I didn't know Groovy or Java a week ago so this is very much my "hello world" program for Groovy. Having said that, it seems to work and nothing has caught fire yet, although there is a strong smell of roses for some reason.

There will be bugs.
It's a work-in-progress/proof of concept at the moment.
I haven't written any documentation apart from this post.

I have version 2 boxes with the battery option. I haven't tested on other variants. Only the version 3 (Air) boxes have the ability to report battery levels. I've coded something but I dont know whether it will be reported correctly until it's tested with an Air box.

Installation

There are 3 driver files involved that have to be installed, one for the API, a child driver for the individual boxes and a child of that that provides a dimmer control for each capsule slot:

The API driver:

https://raw.githubusercontent.com/GuySprackland/hubitat-moodo/main/moodoAPI.groovy

The Box driver:

https://raw.githubusercontent.com/GuySprackland/hubitat-moodo/main/moodoBox.groovy

The capsule slot driver:

https://raw.githubusercontent.com/GuySprackland/hubitat-moodo/main/moodoSlot.groovy

Create a device of type Moodo API. Don't create box or slot drivers, the API driver will do that for you.

In the settings for the API device enter your Moodo email and password and click Connect. The driver will create a box device for each Moodo box you have.

Installation, if you're not familiar with the process:

  1. For each of the 3 links above:
    1.1. Copy the link
    1.2. In the Hubitat web interface, select Drivers Code in the left menu
    1.3. Click the New Driver button
    1.4. Click Import in the top right
    1.5. Paste the link from above into the input field in the box
    1.6. Click the Import button in the Box
    1.7. Click the OK button in the Are you sure... box
    1.8. Click the Save button

  2. In the Hubitat web interface, select Devices in the left menu

  3. Click Add Virtual Device

  4. Name the device anything you like, I used "Moodo Session"

  5. In the Type box, scroll down to the bottom and choose "Moodo API"

  6. Click Save Device

  7. The device information page is now displayed

  8. Type your Moodo login information into the Connect box (this isn't saved)

  9. Click Connect

  10. If all is well, loginStatus: 1 will be shown under Current States

  11. Refreshing the web browser page (not the device refresh) will show a list of your devices under State Variables

  12. The devices page in the Hubitat web interface will show your Moodo boxes as child devices of the API device created here.

There is a polling option until/if I get realtime updates working.

Turning on logging in the API device logs all requests/responses to/from Moodo.

Use

For the API device, the on/off switch turns polling on and off. It has no effect on the state of the boxes themselves. You can add the Moodo API device into a scene to turn off polling overnight or when away for example. You can change the poll interval with the setPollInterval command. It's in seconds, so 900 would be 15 minutes. Setting the poll interval to 0 disables polling, regardless of the state of the on/off switch.

The Moodo Box device can be treated as a switch or a dimmer from scenes or rules.

In addition it supports the following custom commands:

setShuffle on
setShuffle off
setInterval on
setInterval off
setMode diffuser
setMode purifier
setIntervalType powerful
setIntervalType efficient
setIntervalType saver
setMood {favourite name or part name}
setMood {favourite}, {fanvolume%}
setMood {favourite}, {fanvolume%}, {runtime in seconds}
kickStart {fanvolume%}
kickStart {fanvolume%}, {runtime in seconds}
kickStart {fanvolume%}, {runtime in seconds}, {favourite}

The "state" attribute follows the "switch" attribute, but is set to "sleeping" when the box is in the off part of an interval cycle. The "switch" state shows "off" when the box goes to sleep.

Other attributes are:

family: The name of the scent family installed in the box.
mood: The current favourite selected.
status: Whether the box is online or offine
charging: true or false
interval, intervalType, shuffle, mode: Reflect the box settings.

The Moodo slot child devices work as switches/dimmers. They are named the same as the box device, followed by "slot" and the capsule slot number.

Adding smells to a scene

The easist way to do this is to create a virtual switch for the smell with Auto Off enabled, then catch the switch in Rule Machine to turn your box on and select the fragrance. You can then just add the virtual switch to your scene.

The above is an example, you don't need all of the settings unless you want to change them. Selecting a fragrance also powers on the box so you just need the setMood(), or use setMood(fragrance,volume) to set the fans to a particular level.

2 Likes

Thank you for this. Going to mess around with this tomorrow.

Download the Hubitat app