1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-03 11:52:20 +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

@@ -185,11 +185,12 @@ bool APIConnection::send_cover_state(cover::Cover *cover) {
auto traits = cover->get_traits();
CoverStateResponse resp{};
resp.key = cover->get_object_id_hash();
resp.legacy_state = (cover->position == cover::COVER_OPEN) ? LEGACY_COVER_STATE_OPEN : LEGACY_COVER_STATE_CLOSED;
resp.legacy_state =
(cover->position == cover::COVER_OPEN) ? enums::LEGACY_COVER_STATE_OPEN : enums::LEGACY_COVER_STATE_CLOSED;
resp.position = cover->position;
if (traits.get_supports_tilt())
resp.tilt = cover->tilt;
resp.current_operation = static_cast<EnumCoverOperation>(cover->current_operation);
resp.current_operation = static_cast<enums::CoverOperation>(cover->current_operation);
return this->send_cover_state_response(resp);
}
bool APIConnection::send_cover_info(cover::Cover *cover) {
@@ -213,13 +214,13 @@ void APIConnection::cover_command(const CoverCommandRequest &msg) {
auto call = cover->make_call();
if (msg.has_legacy_command) {
switch (msg.legacy_command) {
case LEGACY_COVER_COMMAND_OPEN:
case enums::LEGACY_COVER_COMMAND_OPEN:
call.set_command_open();
break;
case LEGACY_COVER_COMMAND_CLOSE:
case enums::LEGACY_COVER_COMMAND_CLOSE:
call.set_command_close();
break;
case LEGACY_COVER_COMMAND_STOP:
case enums::LEGACY_COVER_COMMAND_STOP:
call.set_command_stop();
break;
}
@@ -246,7 +247,7 @@ bool APIConnection::send_fan_state(fan::FanState *fan) {
if (traits.supports_oscillation())
resp.oscillating = fan->oscillating;
if (traits.supports_speed())
resp.speed = static_cast<EnumFanSpeed>(fan->speed);
resp.speed = static_cast<enums::FanSpeed>(fan->speed);
return this->send_fan_state_response(resp);
}
bool APIConnection::send_fan_info(fan::FanState *fan) {
@@ -441,8 +442,8 @@ bool APIConnection::send_climate_state(climate::Climate *climate) {
auto traits = climate->get_traits();
ClimateStateResponse resp{};
resp.key = climate->get_object_id_hash();
resp.mode = static_cast<EnumClimateMode>(climate->mode);
resp.action = static_cast<EnumClimateAction>(climate->action);
resp.mode = static_cast<enums::ClimateMode>(climate->mode);
resp.action = static_cast<enums::ClimateAction>(climate->action);
if (traits.get_supports_current_temperature())
resp.current_temperature = climate->current_temperature;
if (traits.get_supports_two_point_target_temperature()) {
@@ -467,7 +468,7 @@ bool APIConnection::send_climate_info(climate::Climate *climate) {
for (auto mode : {climate::CLIMATE_MODE_AUTO, climate::CLIMATE_MODE_OFF, climate::CLIMATE_MODE_COOL,
climate::CLIMATE_MODE_HEAT}) {
if (traits.supports_mode(mode))
msg.supported_modes.push_back(static_cast<EnumClimateMode>(mode));
msg.supported_modes.push_back(static_cast<enums::ClimateMode>(mode));
}
msg.visual_min_temperature = traits.get_visual_min_temperature();
msg.visual_max_temperature = traits.get_visual_max_temperature();