json

 

 

1. Create a Static JSON File in your HA config folder

/data/homeassistant202405/vacumm/rooms.json

{
  "rooms": [
    {
      "name": "Living Room",
      "action": "vacuum_and_mop",
      "deebot_room_id": 1
    },
    {
      "name": "Bedroom",
      "action": "vacuum_only",
      "deebot_room_id": 2
    },
    {
      "name": "Kitchen",
      "action": "mop_only",
      "deebot_room_id": 3
    }
  ]
}

 

2.

The allowlist_external_dirs: directory must be defined in your homeassistant: section of configuration.yaml

homeassistant:
  allowlist_external_dirs:
    - /config/vacumm
    - /config/image

 

3. Enable File Access and REST API  In configuration.yaml

In configuration.yaml, ensure the file and rest_command integrations are enabled:

#
# ----------------------------------- json file -----------------------------------
#
# https://community.home-assistant.io/t/allowlist-external-dirs/854545/2?u=msly
homeassistant:
  allowlist_external_dirs:
    - /config/vacumm
    - /config/image

# https://www.home-assistant.io/integrations/rest_command/
rest_command:
  write_rooms_json:
    url: "http://localhost:8123/api/config/vacumm/rooms.json"
    method: POST
    headers:
      Authorization: "Bearer YOUR_LONG_LIVED_ACCESS_TOKEN"
      Content-Type: "application/json"
    payload: "{{ updated_json }}"

 

4.To call it in developer tools, script or automation:

action: rest_command.write_rooms_json

action: rest_command.write_rooms_json
data: 
  name: 'Hellstormovo bezva radio!'
  deebot_room_id: 'http://opml.radiotime.com/Tune.ashx?id=s14991'

 

 

Creating sensors from json list

https://community.home-assistant.io/t/creating-sensors-from-json-list/319512/6

 

Comments


Comments are closed