antenna-switcher-client 0.5.0
Async C++17 client for the antenna-switcher device over the ESPHome native API
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
antenna_switcher::AntennaSwitcher Class Reference

Async, event-driven controller for the antenna-switcher device. More...

#include <client.hpp>

Public Types

using StateCallback = std::function< void(Channel, const ChannelState &)>
 Called with the channel and its new state after each state update.
 

Public Member Functions

 AntennaSwitcher (Options opts)
 
 ~AntennaSwitcher ()
 
 AntennaSwitcher (const AntennaSwitcher &)=delete
 
AntennaSwitcheroperator= (const AntennaSwitcher &)=delete
 
void connect () const
 Connect, enumerate entities, and resolve the per-channel handles.
 
void disconnect () const
 Gracefully disconnect and stop the worker thread.
 
bool isConnected () const
 
void setInput (Channel channel, int input) const
 Select input input (1..10) on channel (sends set:N).
 
void startAuto (Channel channel, int interval, TimeUnit unit, const std::vector< int > &inputs={}) const
 Start auto-cycling channel with the given interval.
 
void runPlan (Channel channel, const std::vector< PlanStep > &steps, bool repeat=false) const
 Run an ordered plan on channel, optionally repeating.
 
void stop (Channel channel) const
 Stop any auto/plan activity on channel (sends stop).
 
void setAngleOffset (Channel channel, int degrees) const
 Set the compass angle offset for input 1 (degrees, written to the number entity).
 
ChannelState state (Channel channel) const
 Thread-safe snapshot of channel's latest state.
 
void onStateChanged (StateCallback cb) const
 Register a state-change listener (invoked on the loop thread).
 

Detailed Description

Async, event-driven controller for the antenna-switcher device.

Owns a background worker thread that drives the ESPHome event loop. Commands are marshalled onto that loop, so the public methods are safe to call from any thread. State-change callbacks run on the loop thread.

Member Typedef Documentation

◆ StateCallback

Called with the channel and its new state after each state update.

Constructor & Destructor Documentation

◆ AntennaSwitcher() [1/2]

antenna_switcher::AntennaSwitcher::AntennaSwitcher ( Options  opts)
explicit

◆ ~AntennaSwitcher()

antenna_switcher::AntennaSwitcher::~AntennaSwitcher ( )

◆ AntennaSwitcher() [2/2]

antenna_switcher::AntennaSwitcher::AntennaSwitcher ( const AntennaSwitcher )
delete

Member Function Documentation

◆ connect()

void antenna_switcher::AntennaSwitcher::connect ( ) const

Connect, enumerate entities, and resolve the per-channel handles.

Blocks until ready; throws (esphome::api::ApiError, std::runtime_error) on failure.

◆ disconnect()

void antenna_switcher::AntennaSwitcher::disconnect ( ) const

Gracefully disconnect and stop the worker thread.

◆ isConnected()

bool antenna_switcher::AntennaSwitcher::isConnected ( ) const

◆ onStateChanged()

void antenna_switcher::AntennaSwitcher::onStateChanged ( StateCallback  cb) const

Register a state-change listener (invoked on the loop thread).

◆ operator=()

AntennaSwitcher & antenna_switcher::AntennaSwitcher::operator= ( const AntennaSwitcher )
delete

◆ runPlan()

void antenna_switcher::AntennaSwitcher::runPlan ( Channel  channel,
const std::vector< PlanStep > &  steps,
bool  repeat = false 
) const

Run an ordered plan on channel, optionally repeating.

◆ setAngleOffset()

void antenna_switcher::AntennaSwitcher::setAngleOffset ( Channel  channel,
int  degrees 
) const

Set the compass angle offset for input 1 (degrees, written to the number entity).

◆ setInput()

void antenna_switcher::AntennaSwitcher::setInput ( Channel  channel,
int  input 
) const

Select input input (1..10) on channel (sends set:N).

◆ startAuto()

void antenna_switcher::AntennaSwitcher::startAuto ( Channel  channel,
int  interval,
TimeUnit  unit,
const std::vector< int > &  inputs = {} 
) const

Start auto-cycling channel with the given interval.

When inputs has 1..9 entries they form the cycle order; empty or all-ten cycles every input.

◆ state()

ChannelState antenna_switcher::AntennaSwitcher::state ( Channel  channel) const

Thread-safe snapshot of channel's latest state.

◆ stop()

void antenna_switcher::AntennaSwitcher::stop ( Channel  channel) const

Stop any auto/plan activity on channel (sends stop).


The documentation for this class was generated from the following file: