1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-10 07:12:21 +01:00

Move native API enums to new namespace (#825)

Fixes https://github.com/esphome/issues/issues/801
This commit is contained in:
Otto Winter
2019-11-02 19:35:45 +01:00
committed by GitHub
parent be6b4ee47f
commit 66aa02fc34
6 changed files with 145 additions and 131 deletions

View File

@@ -5,26 +5,28 @@
namespace esphome {
namespace api {
enum EnumLegacyCoverState : uint32_t {
namespace enums {
enum LegacyCoverState : uint32_t {
LEGACY_COVER_STATE_OPEN = 0,
LEGACY_COVER_STATE_CLOSED = 1,
};
enum EnumCoverOperation : uint32_t {
enum CoverOperation : uint32_t {
COVER_OPERATION_IDLE = 0,
COVER_OPERATION_IS_OPENING = 1,
COVER_OPERATION_IS_CLOSING = 2,
};
enum EnumLegacyCoverCommand : uint32_t {
enum LegacyCoverCommand : uint32_t {
LEGACY_COVER_COMMAND_OPEN = 0,
LEGACY_COVER_COMMAND_CLOSE = 1,
LEGACY_COVER_COMMAND_STOP = 2,
};
enum EnumFanSpeed : uint32_t {
enum FanSpeed : uint32_t {
FAN_SPEED_LOW = 0,
FAN_SPEED_MEDIUM = 1,
FAN_SPEED_HIGH = 2,
};
enum EnumLogLevel : uint32_t {
enum LogLevel : uint32_t {
LOG_LEVEL_NONE = 0,
LOG_LEVEL_ERROR = 1,
LOG_LEVEL_WARN = 2,
@@ -33,7 +35,7 @@ enum EnumLogLevel : uint32_t {
LOG_LEVEL_VERBOSE = 5,
LOG_LEVEL_VERY_VERBOSE = 6,
};
enum EnumServiceArgType : uint32_t {
enum ServiceArgType : uint32_t {
SERVICE_ARG_TYPE_BOOL = 0,
SERVICE_ARG_TYPE_INT = 1,
SERVICE_ARG_TYPE_FLOAT = 2,
@@ -43,17 +45,20 @@ enum EnumServiceArgType : uint32_t {
SERVICE_ARG_TYPE_FLOAT_ARRAY = 6,
SERVICE_ARG_TYPE_STRING_ARRAY = 7,
};
enum EnumClimateMode : uint32_t {
enum ClimateMode : uint32_t {
CLIMATE_MODE_OFF = 0,
CLIMATE_MODE_AUTO = 1,
CLIMATE_MODE_COOL = 2,
CLIMATE_MODE_HEAT = 3,
};
enum EnumClimateAction : uint32_t {
enum ClimateAction : uint32_t {
CLIMATE_ACTION_OFF = 0,
CLIMATE_ACTION_COOLING = 2,
CLIMATE_ACTION_HEATING = 3,
};
} // namespace enums
class HelloRequest : public ProtoMessage {
public:
std::string client_info{}; // NOLINT
@@ -212,11 +217,11 @@ class ListEntitiesCoverResponse : public ProtoMessage {
};
class CoverStateResponse : public ProtoMessage {
public:
uint32_t key{0}; // NOLINT
EnumLegacyCoverState legacy_state{}; // NOLINT
float position{0.0f}; // NOLINT
float tilt{0.0f}; // NOLINT
EnumCoverOperation current_operation{}; // NOLINT
uint32_t key{0}; // NOLINT
enums::LegacyCoverState legacy_state{}; // NOLINT
float position{0.0f}; // NOLINT
float tilt{0.0f}; // NOLINT
enums::CoverOperation current_operation{}; // NOLINT
void encode(ProtoWriteBuffer buffer) const override;
void dump_to(std::string &out) const override;
@@ -226,14 +231,14 @@ class CoverStateResponse : public ProtoMessage {
};
class CoverCommandRequest : public ProtoMessage {
public:
uint32_t key{0}; // NOLINT
bool has_legacy_command{false}; // NOLINT
EnumLegacyCoverCommand legacy_command{}; // NOLINT
bool has_position{false}; // NOLINT
float position{0.0f}; // NOLINT
bool has_tilt{false}; // NOLINT
float tilt{0.0f}; // NOLINT
bool stop{false}; // NOLINT
uint32_t key{0}; // NOLINT
bool has_legacy_command{false}; // NOLINT
enums::LegacyCoverCommand legacy_command{}; // NOLINT
bool has_position{false}; // NOLINT
float position{0.0f}; // NOLINT
bool has_tilt{false}; // NOLINT
float tilt{0.0f}; // NOLINT
bool stop{false}; // NOLINT
void encode(ProtoWriteBuffer buffer) const override;
void dump_to(std::string &out) const override;
@@ -262,7 +267,7 @@ class FanStateResponse : public ProtoMessage {
uint32_t key{0}; // NOLINT
bool state{false}; // NOLINT
bool oscillating{false}; // NOLINT
EnumFanSpeed speed{}; // NOLINT
enums::FanSpeed speed{}; // NOLINT
void encode(ProtoWriteBuffer buffer) const override;
void dump_to(std::string &out) const override;
@@ -276,7 +281,7 @@ class FanCommandRequest : public ProtoMessage {
bool has_state{false}; // NOLINT
bool state{false}; // NOLINT
bool has_speed{false}; // NOLINT
EnumFanSpeed speed{}; // NOLINT
enums::FanSpeed speed{}; // NOLINT
bool has_oscillating{false}; // NOLINT
bool oscillating{false}; // NOLINT
void encode(ProtoWriteBuffer buffer) const override;
@@ -448,7 +453,7 @@ class TextSensorStateResponse : public ProtoMessage {
};
class SubscribeLogsRequest : public ProtoMessage {
public:
EnumLogLevel level{}; // NOLINT
enums::LogLevel level{}; // NOLINT
bool dump_config{false}; // NOLINT
void encode(ProtoWriteBuffer buffer) const override;
void dump_to(std::string &out) const override;
@@ -458,7 +463,7 @@ class SubscribeLogsRequest : public ProtoMessage {
};
class SubscribeLogsResponse : public ProtoMessage {
public:
EnumLogLevel level{}; // NOLINT
enums::LogLevel level{}; // NOLINT
std::string tag{}; // NOLINT
std::string message{}; // NOLINT
bool send_failed{false}; // NOLINT
@@ -544,8 +549,8 @@ class GetTimeResponse : public ProtoMessage {
};
class ListEntitiesServicesArgument : public ProtoMessage {
public:
std::string name{}; // NOLINT
EnumServiceArgType type{}; // NOLINT
std::string name{}; // NOLINT
enums::ServiceArgType type{}; // NOLINT
void encode(ProtoWriteBuffer buffer) const override;
void dump_to(std::string &out) const override;
@@ -639,7 +644,7 @@ class ListEntitiesClimateResponse : public ProtoMessage {
std::string unique_id{}; // NOLINT
bool supports_current_temperature{false}; // NOLINT
bool supports_two_point_target_temperature{false}; // NOLINT
std::vector<EnumClimateMode> supported_modes{}; // NOLINT
std::vector<enums::ClimateMode> supported_modes{}; // NOLINT
float visual_min_temperature{0.0f}; // NOLINT
float visual_max_temperature{0.0f}; // NOLINT
float visual_temperature_step{0.0f}; // NOLINT
@@ -656,13 +661,13 @@ class ListEntitiesClimateResponse : public ProtoMessage {
class ClimateStateResponse : public ProtoMessage {
public:
uint32_t key{0}; // NOLINT
EnumClimateMode mode{}; // NOLINT
enums::ClimateMode mode{}; // NOLINT
float current_temperature{0.0f}; // NOLINT
float target_temperature{0.0f}; // NOLINT
float target_temperature_low{0.0f}; // NOLINT
float target_temperature_high{0.0f}; // NOLINT
bool away{false}; // NOLINT
EnumClimateAction action{}; // NOLINT
enums::ClimateAction action{}; // NOLINT
void encode(ProtoWriteBuffer buffer) const override;
void dump_to(std::string &out) const override;
@@ -674,7 +679,7 @@ class ClimateCommandRequest : public ProtoMessage {
public:
uint32_t key{0}; // NOLINT
bool has_mode{false}; // NOLINT
EnumClimateMode mode{}; // NOLINT
enums::ClimateMode mode{}; // NOLINT
bool has_target_temperature{false}; // NOLINT
float target_temperature{0.0f}; // NOLINT
bool has_target_temperature_low{false}; // NOLINT