Add mode to number entities (#148)

This commit is contained in:
Jesse Hills 2021-11-30 22:23:18 +13:00 committed by GitHub
parent 9d89f377bd
commit 759e2ef133
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 112 additions and 54 deletions

View File

@ -857,6 +857,11 @@ message ClimateCommandRequest {
}
// ==================== NUMBER ====================
enum NumberMode {
NUMBER_MODE_AUTO = 0;
NUMBER_MODE_BOX = 1;
NUMBER_MODE_SLIDER = 2;
}
message ListEntitiesNumberResponse {
option (id) = 49;
option (source) = SOURCE_SERVER;
@ -874,6 +879,7 @@ message ListEntitiesNumberResponse {
bool disabled_by_default = 9;
EntityCategory entity_category = 10;
string unit_of_measurement = 11;
NumberMode mode = 12;
}
message NumberStateResponse {
option (id) = 50;

File diff suppressed because one or more lines are too long

View File

@ -539,6 +539,12 @@ class ClimateState(EntityState):
# ==================== NUMBER ====================
class NumberMode(APIIntEnum):
AUTO = 0
BOX = 1
SLIDER = 2
@dataclass(frozen=True)
class NumberInfo(EntityInfo):
min_value: float = converter_field(
@ -551,6 +557,9 @@ class NumberInfo(EntityInfo):
default=0.0, converter=fix_float_single_double_conversion
)
unit_of_measurement: str = ""
mode: Optional[NumberMode] = converter_field(
default=NumberMode.AUTO, converter=NumberMode.convert
)
@dataclass(frozen=True)