95 const std::vector<int>& inputs = {})
const;
97 void runPlan(
Channel channel,
const std::vector<PlanStep>& steps,
bool repeat =
false)
const;
109 void shutdown_worker()
const;
112 std::unique_ptr<Impl> impl_;
119std::string build_set_input(
int input);
120std::string build_start_auto(
int interval,
TimeUnit unit,
const std::vector<int>& inputs);
121std::string build_run_plan(
const std::vector<PlanStep>& steps,
bool repeat);
122std::string build_stop();
Async, event-driven controller for the antenna-switcher device.
Definition client.hpp:69
void runPlan(Channel channel, const std::vector< PlanStep > &steps, bool repeat=false) const
Run an ordered plan on channel, optionally repeating.
void onStateChanged(StateCallback cb) const
Register a state-change listener (invoked on the loop thread).
void connect() const
Connect, enumerate entities, and resolve the per-channel handles.
void setInput(Channel channel, int input) const
Select input input (1..10) on channel (sends set:N).
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.
AntennaSwitcher(const AntennaSwitcher &)=delete
AntennaSwitcher & operator=(const AntennaSwitcher &)=delete
void startAuto(Channel channel, int interval, TimeUnit unit, const std::vector< int > &inputs={}) const
Start auto-cycling channel with the given interval.
AntennaSwitcher(Options opts)
void disconnect() const
Gracefully disconnect and stop the worker thread.
std::function< void(Channel, const ChannelState &)> StateCallback
Called with the channel and its new state after each state update.
Definition client.hpp:72
Channel
One of the two switchers on the device.
Definition client.hpp:21
TimeUnit
Time unit for auto-cycle intervals and plan delays.
Definition client.hpp:24
Mode
Operating mode reported by the device.
Definition client.hpp:27
A snapshot of one channel's live state.
Definition client.hpp:47
int angleOffset
Compass offset for input 1, in degrees (0..359).
Definition client.hpp:50
int activeInput
Currently selected input (1..10), 0 if unknown.
Definition client.hpp:49
std::vector< int > activeInputs
Inputs in the current auto cycle (CSV-parsed).
Definition client.hpp:53
Mode mode
Manual / auto / plan.
Definition client.hpp:52
long intervalUs
Auto-cycle interval in microseconds.
Definition client.hpp:51
int bearing
Current compass bearing in degrees.
Definition client.hpp:48
Everything needed to reach and authenticate with the device.
Definition client.hpp:57
std::string client_info
Identification sent in HelloRequest.
Definition client.hpp:61
std::string host
Device hostname or IP.
Definition client.hpp:58
std::uint16_t port
ESPHome native API port.
Definition client.hpp:59
std::string noise_psk
base64 Noise key (api.encryption.key); empty ⇒ plaintext.
Definition client.hpp:60
One step of a plan: either switch to an input, or wait for a delay.
Definition client.hpp:30
enum antenna_switcher::PlanStep::Kind kind
TimeUnit unit
Definition client.hpp:34
int input
Definition client.hpp:32
Kind
Definition client.hpp:31
int delay
Definition client.hpp:33
static PlanStep input_step(const int n)
A step that selects input n (1..10).
Definition client.hpp:37
static PlanStep delay_step(const int value, const TimeUnit unit=TimeUnit::Ms)
A step that waits value in unit.
Definition client.hpp:41