How can I integrate my lights into Home Assistant?(Controlled by REST API)

How can I integrate my lights into Home Assistant?
All the lights in my home are controlled by REST API by intranet.

Dear All,
I’m not that good at English so I hope you understand.

Actually, my lights are controlled by REST API from my apartment’s server as below.

APARTMENT_SERVER/v2/api/livinglight/turnOn
APARTMENT_SERVER/v2/api/livinglight/turnOff
APARTMENT_SERVER/v2/api/livinglight/states

One of our resident has found these APIs from decompiling related mobile app.
So I want to introduce how to integrate our entities into HA.

  1. Is there any easy way to add entities into Home Assistant? I can find informations on internet, so please let me know core words or some related web pages. (I can’t find now :()

  2. How can I maintain the status of the device? I mean, there is a “states” API but I’m really care to be blocked by the administrator of the server if I call it every minutes.

  3. I think HA doesn’t have to know the status all the time. I need just can do on/off commands from HA. Is there a good way?

  4. I need to apply access_token in every APIs and I can retrive it by login API. This token is expired in every hours. How can I handle it? (ADDED)

Thanks for reading my thread and thank you in advance!

1 Like

Thanks a lot! I checked it but there is one more problem.
I need to apply access_token in header for every APIs and I can retrive it by login API. This token is expired in every hours. How can I handle it?

You can add the access token to the headers of the restful call.

If you’re asking how to automate the retrieval of the token, that’s an entirely different story.

Yes I need to know how to automate the retrieval of the token… I’m looking for the best pratice for this. maybe I can get token every swich’s operations…?

There are no “best practices”.
You’ll have to find out how to get the access token without human intervention (likely another API), then you can automate it.

1 Like

Ahh thanks! I’ll figure that out :slight_smile: