Esphome climate add action (#2)

Esphome climate fix

Co-authored-by: Otto Winter <otto@otto-winter.com>
This commit is contained in:
Otto Winter 2019-10-18 10:40:05 +02:00 committed by GitHub
commit 41fa3609d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 84 additions and 22 deletions

View File

@ -644,6 +644,12 @@ enum ClimateMode {
CLIMATE_MODE_COOL = 2;
CLIMATE_MODE_HEAT = 3;
}
enum ClimateAction {
CLIMATE_ACTION_OFF = 0;
// values same as mode for readability
CLIMATE_ACTION_COOLING = 2;
CLIMATE_ACTION_HEATING = 3;
}
message ListEntitiesClimateResponse {
option (id) = 46;
option (source) = SOURCE_SERVER;
@ -661,6 +667,7 @@ message ListEntitiesClimateResponse {
float visual_max_temperature = 9;
float visual_temperature_step = 10;
bool supports_away = 11;
bool supports_action = 12;
}
message ClimateStateResponse {
option (id) = 47;
@ -675,6 +682,7 @@ message ClimateStateResponse {
float target_temperature_low = 5;
float target_temperature_high = 6;
bool away = 7;
ClimateAction action = 8;
}
message ClimateCommandRequest {
option (id) = 48;

File diff suppressed because one or more lines are too long

View File

@ -184,6 +184,12 @@ class ClimateMode(enum.IntEnum):
HEAT = 3
class ClimateAction(enum.IntEnum):
OFF = 0
COOLING = 2
HEATING = 3
def _convert_climate_modes(value):
return [ClimateMode(val) for val in value]
@ -197,11 +203,13 @@ class ClimateInfo(EntityInfo):
visual_max_temperature = attr.ib(type=float)
visual_temperature_step = attr.ib(type=float)
supports_away = attr.ib(type=bool)
supports_action = attr.ib(type=bool)
@attr.s
class ClimateState(EntityState):
mode = attr.ib(type=ClimateMode, converter=ClimateMode)
action = attr.ib(type=ClimateAction, converter=ClimateAction)
current_temperature = attr.ib(type=float)
target_temperature = attr.ib(type=float)
target_temperature_low = attr.ib(type=float)