Hi,
Can anyone help me out on how to add and delete a new device in the home assistant front-end using the REST API and not by yaml files?
The REST API documentation lists what possible and how it’s done.
Thanks. I had gone through the REST API documentation, and it seems that we cannot add devices using REST API from the front-end. Any idea of why is there a limitation like that?
This snippet would add a new binary sensor to the fronend:
$ curl -X POST -H "x-ha-access: YOUR_PASSWORD" \
-H "Content-Type: application/json" \
-d '{"state": "off", "attributes": {"friendly_name": "Radio"}}' \
http://localhost:8123/api/states/binary_sensor.radio
But yes, you can’t use the Developer tools to do it.
Thank you @fabaff. However, the information is not persisting once we restart the hass, since it is not written into the yaml file. Is there a way to make them persist?
No. It depends on the use case but it doesn’t need to be persistent as after the restart the entity is re-created when the first message from the sensor arrives (if the device is still running).
@fabaff, Can we use the same approach for automation also? If not, is there any other way to do it? Thanks.
automations are entities, so i guess it should be possible (but i have no clue how
@fabaff if i use restfull api to create an input_boolean it shows up like expected in the frontend.
from that moment i can set the state from the boolean through api, but the frontend doesnt accept changes from the boolean.
should it be possible to create a working boolean through api?
Thanks. It updates the entity state in the front-end, but it doesn’t get triggered unless there is an automation entry in the yaml file itself. Also, I came across the automation editor by @fabaff. Anyways will check that out too.
@fabaff. I have checked the automation editor. It works fine. Can I use any similar approach for the Scenes too?
Thanks.