class ShellyplugExporter::PlugClient

Overview

Handles HTTP communication with a single Shelly plug device.

Defined in:

shellyplug_exporter/plug_client.cr

Constant Summary

CONNECT_TIMEOUT = 4.seconds
READ_TIMEOUT = 4.seconds
SHELLY_ENDPOINT = "/shelly"

Constructors

Instance Method Summary

Constructor Detail

def self.new(config : PlugConfig) #

Instance Method Detail

def detect_generation : PlugGeneration #

Detects the plug generation by probing the /shelly endpoint. Gen2 and later devices include a "gen" field in their response and all serve the same RPC API, so Gen3 and Gen4 are handled as Gen2. Returns the detected PlugGeneration, defaulting to Gen1 on failure.


def fetch_settings : HTTP::Client::Response #

Fetches the settings/config from the plug.


def fetch_status : HTTP::Client::Response #

Fetches the status from the plug.