State const
This commit is contained in:
@ -84,7 +84,7 @@ class ClimateEntity extends Entity {
|
||||
String get fanMode => attributes['fan_mode'];
|
||||
String get swingMode => attributes['swing_mode'];
|
||||
bool get awayMode => attributes['away_mode'] == "on";
|
||||
bool get isOff => state == "off";
|
||||
bool get isOff => state == EntityState.off;
|
||||
bool get auxHeat => attributes['aux_heat'] == "on";
|
||||
|
||||
ClimateEntity(Map rawData) : super(rawData);
|
||||
|
31
lib/entity_class/const.dart
Normal file
31
lib/entity_class/const.dart
Normal file
@ -0,0 +1,31 @@
|
||||
part of '../main.dart';
|
||||
|
||||
class EntityState {
|
||||
static const on = 'on';
|
||||
static const off = 'off';
|
||||
static const home = 'home';
|
||||
static const not_home = 'not_home';
|
||||
static const unknown = 'unknown';
|
||||
static const open = 'open';
|
||||
static const opening = 'opening';
|
||||
static const closed = 'closed';
|
||||
static const closing = 'closing';
|
||||
static const playing = 'playing';
|
||||
static const paused = 'paused';
|
||||
static const idle = 'idle';
|
||||
static const standby = 'standby';
|
||||
static const alarm_disarmed = 'disarmed';
|
||||
static const alarm_armed_home = 'armed_home';
|
||||
static const alarm_armed_away = 'armed_away';
|
||||
static const alarm_armed_night = 'armed_night';
|
||||
static const alarm_armed_custom_bypass = 'armed_custom_bypass';
|
||||
static const alarm_pending = 'pending';
|
||||
static const alarm_arming = 'arming';
|
||||
static const alarm_disarming = 'disarming';
|
||||
static const alarm_triggered = 'triggered';
|
||||
static const locked = 'locked';
|
||||
static const unlocked = 'unlocked';
|
||||
static const unavailable = 'unavailable';
|
||||
static const ok = 'ok';
|
||||
static const problem = 'problem';
|
||||
}
|
@ -40,8 +40,8 @@ class CoverEntity extends Entity {
|
||||
|
||||
double get currentPosition => _getDoubleAttributeValue('current_position');
|
||||
double get currentTiltPosition => _getDoubleAttributeValue('current_tilt_position');
|
||||
bool get canBeOpened => ((state != "opening") && (state != "open")) || (state == "open" && currentPosition != null && currentPosition > 0.0 && currentPosition < 100.0);
|
||||
bool get canBeClosed => ((state != "closing") && (state != "closed"));
|
||||
bool get canBeOpened => ((state != EntityState.opening) && (state != EntityState.open)) || (state == EntityState.open && currentPosition != null && currentPosition > 0.0 && currentPosition < 100.0);
|
||||
bool get canBeClosed => ((state != EntityState.closing) && (state != EntityState.closed));
|
||||
bool get canTiltBeOpened => currentTiltPosition < 100;
|
||||
bool get canTiltBeClosed => currentTiltPosition > 0;
|
||||
|
||||
|
@ -2,10 +2,6 @@ part of '../main.dart';
|
||||
|
||||
class Entity {
|
||||
|
||||
static const badgeColors = {
|
||||
"default": Color.fromRGBO(223, 76, 30, 1.0),
|
||||
"binary_sensor": Color.fromRGBO(3, 155, 229, 1.0)
|
||||
};
|
||||
static List badgeDomains = [
|
||||
"alarm_control_panel",
|
||||
"binary_sensor",
|
||||
@ -39,7 +35,7 @@ class Entity {
|
||||
bool get isGroup => domain == "group";
|
||||
bool get isBadge => Entity.badgeDomains.contains(domain);
|
||||
String get icon => attributes["icon"] ?? "";
|
||||
bool get isOn => state == "on";
|
||||
bool get isOn => state == EntityState.on;
|
||||
String get entityPicture => attributes["entity_picture"];
|
||||
String get unitOfMeasurement => attributes["unit_of_measurement"] ?? "";
|
||||
List get childEntityIds => attributes["entity_id"] ?? [];
|
||||
|
Reference in New Issue
Block a user