RESTful or not? Rituals Perfume Genie

I got this working as well. However I am hoping to find this in an actual integration and not something spiffy we come with.
I found a Rituals API and that seems to be able to connect to the API and retrieve all the information in JSON format. The problem is I am running into my Python limitations.

The API can be downloaded here: https://pypi.org/project/rituals-api/#files

A simple way of using this is:

from rituals import RitualsAPI;

rituals = RitualsAPI(<email>, <password>);
hub=rituals.availableHubs();
print(hub);

I have no experience with building my own APIs, nor with HA integrations… I am willing to help of course, if some one can help with this API.

I am a few step further now:

from rituals import RitualsAPI

rituals = RitualsAPI(<EMAIL>, <PASSWORD>)

hub=rituals.availableHubs()

for key in hub:
  print(rituals.hubs[key]['attributes']['fanc'])
  print(rituals.hubs[key]['sensors']['fillc']['title'])
  print(rituals.hubs[key]['sensors']['rfidc']['title'])
  print(rituals.hubs[key]['sensors']['wific']['title'])

This will output the same as the rest API (fan status, fill capacity, type of scent and wifi connection strenght).
I also found the PNGs and ICONs that are referred in the JSON response. They are part of the application, in order to get them simply download the APK and unpack it.

I will see if I can create an integration but from the looks of it, it is too complex for me.

thanks @Noto,

was looking for a way to do just that, also added the room size using your code

sensor:

rest_command:
genie_tiny15:
method: post
url: ‘https://rituals.sense-company.com/api/hub/update/attr?hub=HERE THE SHORT CODE&json=%7B%22attr%22%3A%7B%22roomc%22%3A%221%22%7D%7D’
content_type: application/json

genie_small30:
method: post
url: ‘https://rituals.sense-company.com/api/hub/update/attr?hub=HERE THE SHORT CODE&json=%7B%22attr%22%3A%7B%22roomc%22%3A%222%22%7D%7D’
content_type: application/json

genie_medium60:
method: post
url: ‘https://rituals.sense-company.com/api/hub/update/attr?hub=HERE THE SHORT CODE&json=%7B%22attr%22%3A%7B%22roomc%22%3A%223%22%7D%7D’
content_type: application/json

genie_large100:
method: post
url: ‘https://rituals.sense-company.com/api/hub/update/attr?hub=HERE THE SHORT CODE&json=%7B%22attr%22%3A%7B%22roomc%22%3A%224%22%7D%7D’
content_type: application/json

Sorry, my Python skills are 0, so am not able to help… but is there any progression?

Sorry, not really… My python skills are not sufficient I am afraid.

I was having some issues since the last few days since the /api/accounts/hubs endpoint doesn’t return all the information anymore. It seems to have reduced attributes to roomnamec (which is an array now?), and the sensors to wific and rfidc.

It is possible to get the other parameters back using a hub specific call /api/accounts/hub/{hub_hash}.

1 Like

Hi!
I’m on Firmware Version: 5.0 now and i can’t switch on/off with this code:

https://rituals.sense-company.com/api/hub/update/attr?hub=HERE THE LONG CODE&json={“attr”:{“fanc”:“1”}}’

is there an other way now?

https://rituals.sense-company.com/ - this side is down?!

greez

indeed attributes seem to have disappeared. also with me 2 sensors no longer work.

when I read the API with a browser, I no longer see the attributes there either. Rituals has changed a bit …

Yes, me too.
can’t see “fillc”, “battc”, “fanc”, …

I reverse engineered the app a bit and found out that all the data can now be fetched from a slightly different url.
hubs becomes hub and you need the short code instead of the long code:
https://rituals.sense-company.com/api/account/hub/THE SHORT CODE

Also in the value templates you need to remove the 0 because the data is not in a list anymore since we fetch the data of only one hub:
value_template: '{{ value_json.0.hub.attributes.fanc == "1" }}'
becomes:
value_template: '{{ value_json.hub.attributes.fanc == "1" }}'

The rest command to turn the genie on and off still works as before.

1 Like

Can you please share the code for the buttons as well?

I hav gotten most to work, but I am still not able to get the On/Off switch to work. This is the code I am using to test with through Terminal in HA:

curl -X POST https://rituals.sense-company.com/api/hub/update/attr?hub=HUB-HASH&json={"attr":{"fanc":"1}}

The URL code should be ok, but I still get an 500 Server Error in return.

This is the rest_command:

rest_command:
  genie_on:
    method: POST
    url: 'https://rituals.sense-company.com/api/hub/update/attr?hub=HUB-HASH&json={"attr":{"fanc":"1}}'
    content_type: application/json
    
  genie_off:
    method: POST
    url: 'https://rituals.sense-company.com/api/hub/update/attr?hub=HUB-HASH&json={"attr":{"fanc":"0"}}'
    content_type: application/json

Could someone that have a working Genie code please share it or pinpoint the error? Thanks!

sensors are working here (version 5) but turning on/off is not like previous post

Any help ?

commands are like this:

genie_on:
  method: post
  url: 'https://rituals.sense-company.com/api/hub/update/attr?hub=short hash here&json=={"attr":{"fanc":"1"}}'
  content_type: application/json
genie_off:
  method: post
  url: 'https://rituals.sense-company.com/api/hub/update/attr?hub=short hash here&json=={"attr":{"fanc":"0"}}'
  content_type: application/json

Should it also be api/account/hub/ in stead of api/hub/ like in the sensors ?

I’ve found the image and discover_image images, they are with in the mobile app, or at least the android one.

In the following link, you’ll find the android app extracted: app.zip

You can find the images in assets\www\img\backgrounds and assets\www\img\discover directories.

discover_url is indeed prefixed, but that took only a simple google to find it:

rituals.com/en-nl/the-ritual-of-hammam-cartridge-1103967.html

Did you install the package using pip?
The package name is rituals-api why do you use import rituals instead of import rituals-api?
I can’t import rituals-api because it has a hyphen in the package name. It works using:

rituals = __import__("rituals-api")

Hi guys
REST command didn’t work for me so I used a workaroudn with curl

shell_command:
    genie_on: "curl --insecure -H 'Content-Type: application/json' -X POST 'https://37.97.128.129/api/hub/update/attr?hub=**<HUB-HASH>**&json=%7B%22attr%22%3A%7B%22fanc%22%3A%221%22%7D%7D'"
    genie_off: "curl --insecure -H 'Content-Type: application/json' -X POST 'https://37.97.128.129/api/hub/update/attr?hub=**<HUB-HASH>**&json=%7B%22attr%22%3A%7B%22fanc%22%3A%220%22%7D%7D'"

It works directly with IP addr (hopefully fixed IP) because my hassio server couldn’t found a working DNS for rituals.sense-company.com.

I made an integration which is installable using HACS (add it as a custom repository). It is found on:

A warning though, this is my first HomeAssistant integration :innocent: . You provide the username and password (which are not stored), and then it allows to select the Genie you want to add. After that it should pop-up in your entities / devices. It should work with multiple Genies, but I only have one, so I haven’t tested that.

4 Likes

Thanks a lot, you saved me tons of troubles :slight_smile: This works perfectly :raised_hands:

Indeed, thank you very much for this component! It just works right out of the box! :slight_smile:
Excellent work for all of us Rituals-owners.

I’ve downloaded your integration using HACS and after rebooting Home Assistant it works perfectly. My Rituals Genie have stopped working with Home Assistant after some update but now it’s working again effortless. Thank you!