unfoldedcircle / integration-home-assistant

Home-Assistant Integration for Remote Two
Mozilla Public License 2.0
28 stars 5 forks source link

Home Assistant WebSocket API connection tool #49

Closed zehnm closed 9 months ago

zehnm commented 9 months ago

The bin/ha_test.rs tool is a simple CLI tool to test the Home Assistant WebSocket API connectivity with the exact same code & logic as the HA integration for Remote Two.

The main purpose of this tool is to troubleshoot connectivity issues from a PC. X64 binaries for Linux, macOS and Windows are automatically built with a GitHub action.

Functionality

  1. Connect to the HA server and authenticate with the token
  2. Subscribe to entity state events: subscribe_events
  3. Request the entity states: get_states
  4. Disconnect

Required parameters

The configuration can either be provided in a home-assistant.json file in the current directory (see ./resources directory for a template), or through command line parameters.

Usage

/ha-test --help
Home Assistant server communication test

Usage: ha-test [OPTIONS]

Options:
  -u <url>                     Home Assistant WebSocket API URL (overrides home-assistant.json) [default: ws://homeassistant.local:8123/api/websocket]
  -t <token>                   Home Assistant long lived access token (overrides home-assistant.json)
  -c <connection_timeout>      TCP connection timeout in seconds (overrides home-assistant.json)
  -r <request_timeout>         Request timeout in seconds (overrides home-assistant.json)
      --trace <MESSAGES>       Message tracing for HA server communication [default: all] [possible values: in, out, all, none]
  -h, --help                   Print help
  -V, --version                Print version