List wifi networks from hassio command line to use in a sensor

Hello All. You can list wifi networks in HASSIO in the networks tab.

Is it programmatically possible to list wifi networks and create a sensor of the data? I was originally going to use a shell command sensor but nmcli isn’t available in the homeassistant container. Is there another way to get this data in home assistant? An api call? I’m open to options.

API:

/network/interface/<interface>/accesspoints

https://developers.home-assistant.io/docs/api/supervisor/endpoints/#network

1 Like

Bingo! Thank-you!

Hi
I tried this:

rest_command:
  listar_redes_wifi:
    url: "http://192.168.1.202:8123/network/interface/wlan0/accesspoints"
    method: GET
    headers:
      Authorization: "Bearer !secret api_supervisor_token"
    content_type: "application/json"

automation
  - id: actualizar_lista_redes_wifi
    alias: Actualizar lista de redes WiFi
    description: Llama al comando para listar redes WiFi disponibles
    trigger:
      - platform: time_pattern
        seconds: "/5"
    action:
      - service: rest_command.listar_redes_wifi
      - service: input_text.set_value
        target:
          entity_id: input_text.redes_wifi
        data:
          value: "{{ value_json }}"
    mode: single

But, it does not work…

this works for me

aps=curl -sSL -H "Authorization: Bearer $(printenv SUPERVISOR_TOKEN)" http://supervisor/network/interface/wlan0/accesspoints