RESTful or not? Rituals Perfume Genie

It’s looking good. Can you turn on/off the Genie with the switch? Then you put the code for getting the hash (short key) at the parfurm level, battery status etc.

Device won’t turn on.

I am getting this message

Logboekdetails (WARNING)

Logger: homeassistant.components.rest_command
Source: components/rest_command/init.py:133
Integration: RESTful Command (documentation, issues)
First occurred: 13:36:23 (2 occurrences)
Last logged: 13:42:42

Error. Url: https://rituals.sense-company.com/api/hub/update/attr?hub=SHORT CODE&json==%7B%22attr%22:%7B%22fanc%22:%221%22%7D%7D. Status code 500.

have you tried this??

binary_sensor:

sensor:

@niekniek89 thxx

Thxx, sensors are now showing information.
The only problem I have now is that the switch is not working

for the switch config you need the long code:

rest_command:
genie_on:
url: ‘https://rituals.sense-company.com/api/hub/update/attr?hub=HERE THE LONG CODE&json={“attr”:{“fanc”:“1”}}’
method: post
content_type: application/json

genie_off:
url: ‘https://rituals.sense-company.com/api/hub/update/attr?hub=HERE THE LONG CODE&json={“attr”:{“fanc”:“0”}}’
method: post
content_type: application/json

There are also references to images in the API response. Has anyone been able to figure out the location of these images? Like for instance in the rfidc section:

“icon”:“icon-hammam.png”,
“image”:“background-hammam.png”,
“discover_image”:“discover-hammam.jpg”

My guess is that the app places a url in front of that to download images. Would be nice to use one of these as the card background.

Also adding a sensor to see the strength may be usefull. And rest commands to change it. I’ve added 3 buttons to the UI to set the strength that call the services.

sensor:
  - platform: template
    sensors:
  - platform: rest
    resource: https://rituals.sense-company.com/api/account/hubs/HERE THE LONG CODE
    method: GET
    name: Genie Strength
    value_template: '{{ value_json.0.hub.attributes.speedc }}'

rest_command:
  genie_low:
    method: post
    url: 'https://rituals.sense-company.com/api/hub/update/attr?hub=HERE THE SHORT CODE&json=%7B%22attr%22%3A%7B%22speedc%22%3A%221%22%7D%7D'
    content_type: application/json
  genie_med:
    method: post
    url: 'https://rituals.sense-company.com/api/hub/update/attr?hub=HERE THE SHORT CODE&json=%7B%22attr%22%3A%7B%22speedc%22%3A%222%22%7D%7D'
    content_type: application/json
  genie_high:
    method: post
    url: 'https://rituals.sense-company.com/api/hub/update/attr?hub=HERE THE SHORT CODE&json=%7B%22attr%22%3A%7B%22speedc%22%3A%223%22%7D%7D'
    content_type: application/json

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 ?