esphome-api-client 0.5.0
Modern C++17 client for the ESPHome native API (plaintext + Noise)
Loading...
Searching...
No Matches
fan.hpp
Go to the documentation of this file.
1#pragma once
2
5
9
10#include <cstdint>
11#include <memory>
12#include <optional>
13#include <string>
14#include <vector>
15
16namespace esphome::api {
17
18namespace proto {
19class ListEntitiesFanResponse;
20class FanStateResponse;
21class FanCommandRequest;
22} // namespace proto
23
27 bool supports_speed = false;
28 bool supports_direction = false;
29 std::int32_t supported_speed_count = 0;
30 std::vector<std::string> supported_preset_modes;
31};
32
34struct FanState {
35 std::uint32_t key = 0;
36 bool state = false;
37 bool oscillating = false;
39 std::int32_t speed_level = 0;
40 std::string preset_mode;
41};
42
44struct FanCommand {
45 std::uint32_t key = 0;
46 std::optional<bool> state;
47 std::optional<bool> oscillating;
48 std::optional<FanDirection> direction;
49 std::optional<std::int32_t> speed_level;
50 std::optional<std::string> preset_mode;
51};
52
53FanInfo parse_fan_info(const proto::ListEntitiesFanResponse& msg);
54FanState parse_fan_state(const proto::FanStateResponse& msg);
55std::unique_ptr<ProtoMessage> to_message(const FanCommand& cmd);
56
57} // namespace esphome::api
Common entity metadata shared by every entity domain.
Typed mirrors of the ESPHome protobuf enums.
Definition bytes.hpp:10
std::unique_ptr< ProtoMessage > to_message(const AlarmControlPanelCommand &cmd)
FanDirection
Mirror of proto enum FanDirection.
Definition enums.hpp:54
FanInfo parse_fan_info(const proto::ListEntitiesFanResponse &msg)
FanState parse_fan_state(const proto::FanStateResponse &msg)
Lightweight base class for every generated ESPHome API message.
Fields present on every ListEntities*Response.
Definition entity.hpp:16
A command to mutate a fan. Each optional field is sent only when engaged.
Definition fan.hpp:44
std::optional< FanDirection > direction
Definition fan.hpp:48
std::optional< bool > state
Definition fan.hpp:46
std::uint32_t key
Definition fan.hpp:45
std::optional< std::string > preset_mode
Definition fan.hpp:50
std::optional< bool > oscillating
Definition fan.hpp:47
std::optional< std::int32_t > speed_level
Definition fan.hpp:49
Static description of a fan entity.
Definition fan.hpp:25
bool supports_speed
Definition fan.hpp:27
std::int32_t supported_speed_count
Definition fan.hpp:29
bool supports_direction
Definition fan.hpp:28
bool supports_oscillation
Definition fan.hpp:26
std::vector< std::string > supported_preset_modes
Definition fan.hpp:30
A fan's reported state.
Definition fan.hpp:34
std::uint32_t key
Definition fan.hpp:35
FanDirection direction
Definition fan.hpp:38
std::int32_t speed_level
Definition fan.hpp:39
bool state
Definition fan.hpp:36
std::string preset_mode
Definition fan.hpp:40
bool oscillating
Definition fan.hpp:37