How to read RESTful sensor-data from another Hass.io instance on the same network?

Reply to my own thread, I got it working!
My solution was to directly control switch/input_boolean on the remote hassio instance, and not trying to read primary hassio sensors with the remote hassio.

So for anyone puzzling with similar setup, here’s my solution:

  1. Create “Long-Lived Access Token” on the remote RPi, the one which has the switches etc. you want to control remotely. You’ll find this token-menu when you click your username one the lower left corner.

  2. Create rest_command

rest_command:
  my_rest_command:
    url: http://(IP_OF_YOUR_2ND_RPI):8123/api/states/ENTITY_NAME_ON_2ND_RPI (e.g. input_boolean.my_switch)
    method: POST
    headers: 
      Authorization: Bearer YOUR_TOKEN_FROM_2ND_RPI
      content-type: 'application/json'
    payload: '{"state":"{{states.ENTITY_NAME_ON_1ST_RPI.state}}"}'
  1. Create automation to trigger your ‘rest_command’ when the input_boolean state changes.
automation:
  - alias: 'my remote automation'
    hide_entity: True
    initial_state: On
    trigger:
      - platform: state
        entity_id: input_boolean.my_switch
    action:
      - service: rest_command.my_rest_command

How it works:
You control e.g. some input_boolean on your main Hass.io instance, (ENTITY_NAME_ON_1ST_RPI) and that action gets cloned to another entity (ENTITY_NAME_ON_2ND_RPI) on the remote Hass.io instance. Change everything written in capital letters (except ‘method POST’) according to your setup.

2 Likes