Rest-command with custom authentication

I want to read out certain values with HA and found that the website has an (undocumented) REST api. I think I should be able to use rest_command but I am a bit puzzled how to approach this as this particular api needs a login first.

The login happens with a POST to a url, e.g. https://app.someapp.com/rest/v1/account/login
in the body some json is sent:
{ "email":"[email protected]", "password":"verysecretpassword", "languageCode":"nl", "autoLogin":false }

After this login a cookie is added:
Set-Cookie: JSESSIONID=BF7AB38085BD0FB7A036A50ABE425C98; Path=/; Secure; HttpOnly

A second call is then made to e.g. https://app.someapp.com/rest/v1/get (http POST) which returns JSON data.The cookie is of course also sent e.g:
[{"id":12146,"lat":51374337,"lon":8452060,"radius":100,"contractorId":45123,"description":"Thuis","active":true,"visible":true,"color":"FDFD53"}]

I would like to expose the returned json (.e.g description) as sensor and show it in a dashboard.

Reading this https://www.home-assistant.io/integrations/rest_command/ I am not sure how to add the login step. So any help or example is appreciated!

1 Like

Hello,
have you solved this issue? I am facing very similar Use Case and would like to know how to approach it.
Thanks

Guy, did you manage? I have a similar question

Thnx