Skip to main content

Python: Asynchronous client for the Rituals Perfume Genie API

GitHub Release Python Versions Project Stage Project Maintenance License

Build Status Code Coverage OpenSSF Scorecard Open in Dev Containers

Sponsor Frenck via GitHub Sponsors

Support Frenck on Patreon

Asynchronous Python client for the Rituals Perfume Genie API.

About

This package allows you to control and monitor Rituals Perfume Genie diffusers programmatically. It is mainly created to allow third-party programs to automate the behavior of a Perfume Genie.

An excellent example of this might be Home Assistant, which allows you to write automations, to turn on your diffuser when you come home.

A word on the rate limit

The Rituals API is rate limited, at roughly 30 requests per hour per IP address at the time of writing. Logins have their own, stricter limit: a dozen or so within an hour locks the account out for a while. This library is built around that:

  • It logs in lazily and reuses its token until it expires (an hour), instead of logging in on every poll.
  • All requests that need a login at the same time share a single login, and a login that just failed isn't retried right away.
  • A rate limit or lockout is remembered: until it is over, requests fail right away with RitualsGenieRateLimitError, without touching the API.
  • A single hubs() call returns the state (on/off, perfume amount, room size, firmware) of all diffusers on the account.
  • Sensors (fill level, perfume, WiFi, battery) are a request per sensor, and are only requested for sensors the diffuser actually has.

What it doesn't do is pace your requests: how often you poll is up to you. Do the math, and remember other clients on the same IP address share the budget. For example, with two diffusers:

What Requests per hour
hubs() every 5 minutes 12
sensors(hub) hourly, 4 sensors × 2 8
Login, once per hour 1
Total 21

That leaves a handful of requests for actually controlling the diffusers. Use sensors(hub, only=[...]) to request just the sensors you need, and never the version sensor: the firmware is part of hubs() already.

Be nice to the API. Rituals has blocked Home Assistant before for polling too much, the sensors in particular, and with that every user of it.

Token reuse works within a client, so create one client and share it.

Installation

pip install ritualsgenie

To use the command-line interface as well:

pip install "ritualsgenie[cli]"

CLI

# Set credentials once via environment variables
export RITUALS_EMAIL="you@example.com"
export RITUALS_PASSWORD="secret"

# List all diffusers and their state
ritualsgenie hubs

# Show the details of a diffuser (by name, hublot or hash), like its model
ritualsgenie info "Living room"

# Show the sensors of a diffuser
ritualsgenie sensors "Living room"

# Turn a diffuser on/off
ritualsgenie on "Living room"
ritualsgenie off "Living room"

# Set the perfume intensity (1-3) and the room size in square meters
ritualsgenie perfume-amount "Living room" 2
ritualsgenie room-size "Living room" 20

# Turn the standby LED off, start a firmware update
ritualsgenie standby-led "Living room" off
ritualsgenie update-firmware "Living room"

# Emit machine-readable JSON
ritualsgenie hubs --json

# Dump raw API responses as JSON, for sharing in an issue
ritualsgenie dump --sensors

Every command looks up the diffusers first, so most commands cost two or three requests. To not log in on every command, the CLI caches the token in ~/.cache/ritualsgenie/ (or $XDG_CACHE_HOME/ritualsgenie/), readable by you only. Set RITUALS_NO_TOKEN_CACHE=1 to disable that.

The dump command redacts the hash, hublot, PIN and the room and space names. Sensor readings are kept as is, including the RFID tag of the cartridge. Have a look before you share it.

Output goes to stdout, errors to stderr, so --json output can be piped safely. Pass the credentials as options or environment variables in that case, so there is no prompt in between.

Usage

import asyncio

from ritualsgenie import RitualsGenie, Sensor


async def main() -> None:
    """Show example on controlling your Rituals Perfume Genie."""
    async with RitualsGenie(email="you@example.com", password="secret") as genie:
        for hub in await genie.hubs():
            state = {True: "on", False: "off", None: "unknown"}[hub.is_on]
            print(f"{hub.name}: {state}")

            sensors = await genie.sensors(hub, only=[Sensor.PERFUME])
            if sensors.perfume_name:
                print(f"Perfume: {sensors.perfume_name}")

            await genie.turn_on(hub.hash)
            await genie.set_perfume_amount(hub.hash, 2)


if __name__ == "__main__":
    asyncio.run(main())

Many properties return None when the API doesn't tell, so "unknown" is never mistaken for "off". Check with is False when that matters.

Sharing a session

Pass your own aiohttp session to share it, like Home Assistant does. The client never closes a session it didn't create:

async with aiohttp.ClientSession() as session:
    genie = RitualsGenie(email="you@example.com", password="secret", session=session)
    hubs = await genie.hubs()

More endpoints

# A single diffuser, by hash
hub = await genie.hub(hub_hash)

# The model, only available through the hublot lookup
details = await genie.hublot(hub.hublot)
print(details.device_version)  # "Genie 2.1"

# Room size in square meters, which sets the category the diffuser works
# with as well. Two requests, see the docstring.
await genie.set_room_square_meters(hub.hash, 20)

# The standby LED
if hub.supports_standby_led:
    await genie.set_standby_led(hub.hash, enabled=False)

# Start a firmware update when one is available
if hub.firmware and hub.firmware.update_available:
    await genie.update_firmware(hub.hash)

Error handling

from ritualsgenie import (
    RitualsGenieAuthenticationError,
    RitualsGenieConnectionError,
    RitualsGenieError,
    RitualsGenieRateLimitError,
    RitualsGenieResponseError,
    RitualsGenieValueError,
)

try:
    await genie.update_firmware(hub.hash)
except RitualsGenieValueError:
    ...  # Invalid argument, caught before anything was sent
except RitualsGenieAuthenticationError:
    ...  # Invalid credentials; a stale token is already retried for you
except RitualsGenieRateLimitError as err:
    ...  # Back off, err.retry_after tells for how long (if known)
except RitualsGenieResponseError as err:
    ...  # The API said no; err.status has the HTTP status, like 409
except RitualsGenieConnectionError:
    ...  # Network trouble, including timeouts
except RitualsGenieError:
    ...  # Anything else

Reusing a token

The token is available as genie.token. Pass it back in when creating a new client to skip a login (and save a request) after a restart:

genie = RitualsGenie(email="you@example.com", password="secret", token=token)

Changelog & Releases

This repository keeps a change log using GitHub's releases functionality. The format of the log is based on Keep a Changelog.

Releases are based on Semantic Versioning, and use the format of MAJOR.MINOR.PATCH. In a nutshell, the version will be incremented based on the following:

  • MAJOR: Incompatible or major changes.
  • MINOR: Backwards-compatible new features and enhancements.
  • PATCH: Backwards-compatible bugfixes and package updates.

Contributing

This is an active open-source project. We are always open to people who want to use the code or contribute to it.

We've set up a separate document for our contribution guidelines.

Thank you for being involved! 😍

Setting up development environment

The easiest way to start, is by opening a CodeSpace here on GitHub, or by using the Dev Container feature of Visual Studio Code.

Open in Dev Containers

This Python project is fully managed using the Poetry dependency manager. But also relies on the use of NodeJS for certain checks during development.

You need at least:

  • Python 3.12+
  • Poetry
  • NodeJS 24+ (including NPM)

To install all packages, including all development requirements:

npm install
poetry install --all-extras

As this repository uses the prek framework, all changes are linted and tested with each commit. You can run all checks and tests manually, using the following command:

poetry run prek run --all-files

To run just the Python tests:

poetry run pytest

Authors & contributors

The original setup of this repository is by Franck Nijhof.

For a full list of all authors and contributors, check the contributor's page.

Disclaimer

This project is an independent, community-driven effort. It is not affiliated with, endorsed by, or supported by Rituals Cosmetics or Sense Company. All product names, trademarks, and registered trademarks are property of their respective owners.

Use this software at your own risk.

License

MIT License

Copyright (c) 2026 Franck Nijhof

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Metadata

Release files for ritualsgenie 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ritualsgenie 0.1.0
File Size Uploaded
ritualsgenie-0.1.0.tar.gz 30.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ritualsgenie 0.1.0
File Interpreter ABI Platform
ritualsgenie-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 60.9 kB

Release files / ritualsgenie-0.1.0.tar.gz

Download URL ritualsgenie-0.1.0.tar.gz
Size 30.1 kB
Tags Source
SHA-256 checksum
How to use checksums
3408847f9d08c3c051f3fa7c2161f8c2021c842571dae8d3f27290535378f49c
BLAKE2b-256 checksum
How to use checksums
0adce1b7d767349926eae1835a9942b833bcb73abb81141624c4cbea5b17ee01
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 5, 2026.

Transparency log

Release files / ritualsgenie-0.1.0-py3-none-any.whl

Download URL ritualsgenie-0.1.0-py3-none-any.whl
Size 30.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ca2e3d5c96a5245c3e82c7a7a2cb4a466f074b2c6176cfb5f0bdac110dfe8119
BLAKE2b-256 checksum
How to use checksums
aeaf1f30155577ca125605f0c15f6279f7874ad02382d4a18594a3f0308e7afc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 5, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page