WIP #106
This commit is contained in:
parent
69f45b52cf
commit
c23034688e
@ -13,7 +13,15 @@ class Entity {
|
|||||||
"default": Color.fromRGBO(223, 76, 30, 1.0),
|
"default": Color.fromRGBO(223, 76, 30, 1.0),
|
||||||
"binary_sensor": Color.fromRGBO(3, 155, 229, 1.0)
|
"binary_sensor": Color.fromRGBO(3, 155, 229, 1.0)
|
||||||
};
|
};
|
||||||
static List badgeDomains = ["alarm_control_panel", "binary_sensor", "device_tracker", "updater", "sun", "timer", "sensor"];
|
static List badgeDomains = [
|
||||||
|
"alarm_control_panel",
|
||||||
|
"binary_sensor",
|
||||||
|
"device_tracker",
|
||||||
|
"updater",
|
||||||
|
"sun",
|
||||||
|
"timer",
|
||||||
|
"sensor"
|
||||||
|
];
|
||||||
|
|
||||||
double rightWidgetPadding = 14.0;
|
double rightWidgetPadding = 14.0;
|
||||||
double leftWidgetPadding = 8.0;
|
double leftWidgetPadding = 8.0;
|
||||||
@ -70,9 +78,7 @@ class Entity {
|
|||||||
Widget buildDefaultWidget(BuildContext context) {
|
Widget buildDefaultWidget(BuildContext context) {
|
||||||
return EntityModel(
|
return EntityModel(
|
||||||
entity: this,
|
entity: this,
|
||||||
child: DefaultEntityContainer(
|
child: DefaultEntityContainer(state: _buildStatePart(context)),
|
||||||
state: _buildStatePart(context)
|
|
||||||
),
|
|
||||||
handleTap: true,
|
handleTap: true,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -86,24 +92,23 @@ class Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildAdditionalControlsForPage(BuildContext context) {
|
Widget _buildAdditionalControlsForPage(BuildContext context) {
|
||||||
return Container(width: 0.0, height: 0.0,);
|
return Container(
|
||||||
|
width: 0.0,
|
||||||
|
height: 0.0,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget buildEntityPageWidget(BuildContext context) {
|
Widget buildEntityPageWidget(BuildContext context) {
|
||||||
return EntityModel(
|
return EntityModel(
|
||||||
entity: this,
|
entity: this,
|
||||||
child: EntityPageContainer(
|
child: EntityPageContainer(children: <Widget>[
|
||||||
children: <Widget> [
|
DefaultEntityContainer(state: _buildStatePartForPage(context)),
|
||||||
DefaultEntityContainer(
|
LastUpdatedWidget(),
|
||||||
state: _buildStatePartForPage(context)
|
Divider(),
|
||||||
),
|
_buildAdditionalControlsForPage(context),
|
||||||
LastUpdatedWidget(),
|
Divider(),
|
||||||
Divider(),
|
EntityAttributesList()
|
||||||
_buildAdditionalControlsForPage(context),
|
]),
|
||||||
Divider(),
|
|
||||||
EntityAttributesList()
|
|
||||||
]
|
|
||||||
),
|
|
||||||
handleTap: false,
|
handleTap: false,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -151,7 +156,6 @@ class Entity {
|
|||||||
return "$v $text";
|
return "$v $text";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class SwitchEntity extends Entity {
|
class SwitchEntity extends Entity {
|
||||||
@ -161,7 +165,6 @@ class SwitchEntity extends Entity {
|
|||||||
Widget _buildStatePart(BuildContext context) {
|
Widget _buildStatePart(BuildContext context) {
|
||||||
return SwitchControlWidget();
|
return SwitchControlWidget();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class ButtonEntity extends Entity {
|
class ButtonEntity extends Entity {
|
||||||
@ -171,7 +174,6 @@ class ButtonEntity extends Entity {
|
|||||||
Widget _buildStatePart(BuildContext context) {
|
Widget _buildStatePart(BuildContext context) {
|
||||||
return ButtonControlWidget();
|
return ButtonControlWidget();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class TextEntity extends Entity {
|
class TextEntity extends Entity {
|
||||||
@ -207,7 +209,9 @@ class SliderEntity extends Entity {
|
|||||||
//width: 200.0,
|
//width: 200.0,
|
||||||
child: Row(
|
child: Row(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
SliderControlWidget(expanded: true,),
|
SliderControlWidget(
|
||||||
|
expanded: true,
|
||||||
|
),
|
||||||
SimpleEntityState(),
|
SimpleEntityState(),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@ -221,22 +225,88 @@ class SliderEntity extends Entity {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget _buildAdditionalControlsForPage(BuildContext context) {
|
Widget _buildAdditionalControlsForPage(BuildContext context) {
|
||||||
return SliderControlWidget(expanded: false,);
|
return SliderControlWidget(
|
||||||
|
expanded: false,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class ClimateEntity extends Entity {
|
class ClimateEntity extends Entity {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
double widgetHeight = 38.0;
|
double widgetHeight = 38.0;
|
||||||
|
|
||||||
List<String> get operationList => (attributes["operation_list"] as List).cast<String>();
|
static const SUPPORT_TARGET_TEMPERATURE = 1;
|
||||||
|
static const SUPPORT_TARGET_TEMPERATURE_HIGH = 2;
|
||||||
|
static const SUPPORT_TARGET_TEMPERATURE_LOW = 4;
|
||||||
|
static const SUPPORT_TARGET_HUMIDITY = 8;
|
||||||
|
static const SUPPORT_TARGET_HUMIDITY_HIGH = 16;
|
||||||
|
static const SUPPORT_TARGET_HUMIDITY_LOW = 32;
|
||||||
|
static const SUPPORT_FAN_MODE = 64;
|
||||||
|
static const SUPPORT_OPERATION_MODE = 128;
|
||||||
|
static const SUPPORT_HOLD_MODE = 256;
|
||||||
|
static const SUPPORT_SWING_MODE = 512;
|
||||||
|
static const SUPPORT_AWAY_MODE = 1024;
|
||||||
|
static const SUPPORT_AUX_HEAT = 2048;
|
||||||
|
static const SUPPORT_ON_OFF = 4096;
|
||||||
|
|
||||||
|
bool get supportTargetTemperature => ((attributes["supported_features"] &
|
||||||
|
ClimateEntity.SUPPORT_TARGET_TEMPERATURE) ==
|
||||||
|
ClimateEntity.SUPPORT_TARGET_TEMPERATURE);
|
||||||
|
bool get supportTargetTemperatureHigh => ((attributes["supported_features"] &
|
||||||
|
ClimateEntity.SUPPORT_TARGET_TEMPERATURE_HIGH) ==
|
||||||
|
ClimateEntity.SUPPORT_TARGET_TEMPERATURE_HIGH);
|
||||||
|
bool get supportTargetTemperatureLow => ((attributes["supported_features"] &
|
||||||
|
ClimateEntity.SUPPORT_TARGET_TEMPERATURE_LOW) ==
|
||||||
|
ClimateEntity.SUPPORT_TARGET_TEMPERATURE_LOW);
|
||||||
|
bool get supportTargetHumidity => ((attributes["supported_features"] &
|
||||||
|
ClimateEntity.SUPPORT_TARGET_HUMIDITY) ==
|
||||||
|
ClimateEntity.SUPPORT_TARGET_HUMIDITY);
|
||||||
|
bool get supportTargetHumidityHigh => ((attributes["supported_features"] &
|
||||||
|
ClimateEntity.SUPPORT_TARGET_HUMIDITY_HIGH) ==
|
||||||
|
ClimateEntity.SUPPORT_TARGET_HUMIDITY_HIGH);
|
||||||
|
bool get supportTargetHumidityLow => ((attributes["supported_features"] &
|
||||||
|
ClimateEntity.SUPPORT_TARGET_HUMIDITY_LOW) ==
|
||||||
|
ClimateEntity.SUPPORT_TARGET_HUMIDITY_LOW);
|
||||||
|
bool get supportFanMode =>
|
||||||
|
((attributes["supported_features"] & ClimateEntity.SUPPORT_FAN_MODE) ==
|
||||||
|
ClimateEntity.SUPPORT_FAN_MODE);
|
||||||
|
bool get supportOperationMode => ((attributes["supported_features"] &
|
||||||
|
ClimateEntity.SUPPORT_OPERATION_MODE) ==
|
||||||
|
ClimateEntity.SUPPORT_OPERATION_MODE);
|
||||||
|
bool get supportHoldMode =>
|
||||||
|
((attributes["supported_features"] & ClimateEntity.SUPPORT_HOLD_MODE) ==
|
||||||
|
ClimateEntity.SUPPORT_HOLD_MODE);
|
||||||
|
bool get supportSwingMode =>
|
||||||
|
((attributes["supported_features"] & ClimateEntity.SUPPORT_SWING_MODE) ==
|
||||||
|
ClimateEntity.SUPPORT_SWING_MODE);
|
||||||
|
bool get supportAwayMode =>
|
||||||
|
((attributes["supported_features"] & ClimateEntity.SUPPORT_AWAY_MODE) ==
|
||||||
|
ClimateEntity.SUPPORT_AWAY_MODE);
|
||||||
|
bool get supportAuxHeat =>
|
||||||
|
((attributes["supported_features"] & ClimateEntity.SUPPORT_AUX_HEAT) ==
|
||||||
|
ClimateEntity.SUPPORT_AUX_HEAT);
|
||||||
|
bool get supportOnOff =>
|
||||||
|
((attributes["supported_features"] & ClimateEntity.SUPPORT_ON_OFF) ==
|
||||||
|
ClimateEntity.SUPPORT_ON_OFF);
|
||||||
|
|
||||||
|
List<String> get operationList => attributes["operation_list"] != null
|
||||||
|
? (attributes["operation_list"] as List).cast<String>()
|
||||||
|
: null;
|
||||||
|
List<String> get fanList => attributes["fan_list"] != null
|
||||||
|
? (attributes["fan_list"] as List).cast<String>()
|
||||||
|
: null;
|
||||||
|
List<String> get swingList => attributes["swing_list"] != null
|
||||||
|
? (attributes["swing_list"] as List).cast<String>()
|
||||||
|
: null;
|
||||||
double get temperature => _getTemperature();
|
double get temperature => _getTemperature();
|
||||||
double get targetHigh => _getTargetHigh();
|
double get targetHigh => _getTargetHigh();
|
||||||
double get targetLow => _getTargetLow();
|
double get targetLow => _getTargetLow();
|
||||||
String get operationMode => attributes['operation_mode'] ?? "";
|
String get operationMode => attributes['operation_mode'];
|
||||||
|
String get fanMode => attributes['fan_mode'];
|
||||||
|
String get swingMode => attributes['swing_mode'];
|
||||||
bool get awayMode => attributes['away_mode'] == "on";
|
bool get awayMode => attributes['away_mode'] == "on";
|
||||||
|
bool get isOff => state == "off";
|
||||||
|
bool get auxHeat => attributes['aux_heat'] == "on";
|
||||||
|
|
||||||
ClimateEntity(Map rawData) : super(rawData);
|
ClimateEntity(Map rawData) : super(rawData);
|
||||||
|
|
||||||
@ -285,8 +355,9 @@ class ClimateEntity extends Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class SelectEntity extends Entity {
|
class SelectEntity extends Entity {
|
||||||
|
List<String> get listOptions => attributes["options"] != null
|
||||||
List<String> get listOptions => attributes["options"]!= null ? (attributes["options"] as List).cast<String>() : [];
|
? (attributes["options"] as List).cast<String>()
|
||||||
|
: [];
|
||||||
|
|
||||||
SelectEntity(Map rawData) : super(rawData);
|
SelectEntity(Map rawData) : super(rawData);
|
||||||
|
|
||||||
@ -294,11 +365,9 @@ class SelectEntity extends Entity {
|
|||||||
Widget _buildStatePart(BuildContext context) {
|
Widget _buildStatePart(BuildContext context) {
|
||||||
return SelectControlWidget();
|
return SelectControlWidget();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class DateTimeEntity extends Entity {
|
class DateTimeEntity extends Entity {
|
||||||
|
|
||||||
bool get hasDate => attributes["has_date"] ?? false;
|
bool get hasDate => attributes["has_date"] ?? false;
|
||||||
bool get hasTime => attributes["has_time"] ?? false;
|
bool get hasTime => attributes["has_time"] ?? false;
|
||||||
int get year => attributes["year"] ?? 1970;
|
int get year => attributes["year"] ?? 1970;
|
||||||
@ -318,7 +387,8 @@ class DateTimeEntity extends Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
DateTime _getDateTimeState() {
|
DateTime _getDateTimeState() {
|
||||||
return DateTime(this.year, this.month, this.day, this.hour, this.minute, this.second);
|
return DateTime(
|
||||||
|
this.year, this.month, this.day, this.hour, this.minute, this.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
String _getFormattedState() {
|
String _getFormattedState() {
|
||||||
@ -327,16 +397,13 @@ class DateTimeEntity extends Entity {
|
|||||||
formattedState += formatDate(dateTimeState, [M, ' ', d, ', ', yyyy]);
|
formattedState += formatDate(dateTimeState, [M, ' ', d, ', ', yyyy]);
|
||||||
}
|
}
|
||||||
if (this.hasTime) {
|
if (this.hasTime) {
|
||||||
formattedState += " "+formatDate(dateTimeState, [HH, ':', nn]);
|
formattedState += " " + formatDate(dateTimeState, [HH, ':', nn]);
|
||||||
}
|
}
|
||||||
return formattedState;
|
return formattedState;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setNewState(newValue) {
|
void setNewState(newValue) {
|
||||||
eventBus.fire(new ServiceCallEvent(domain, "set_datetime",entityId,
|
eventBus
|
||||||
newValue));
|
.fire(new ServiceCallEvent(domain, "set_datetime", entityId, newValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -238,14 +238,27 @@ class _ClimateControlWidgetState extends State<ClimateControlWidget> {
|
|||||||
bool _changedHere = false;
|
bool _changedHere = false;
|
||||||
Timer _resetTimer;
|
Timer _resetTimer;
|
||||||
double _tmpTemperature = 0.0;
|
double _tmpTemperature = 0.0;
|
||||||
String _tmpOperationMode = "";
|
double _tmpTargetLow = 0.0;
|
||||||
|
double _tmpTargetHigh = 0.0;
|
||||||
|
String _tmpOperationMode;
|
||||||
|
String _tmpFanMode;
|
||||||
|
String _tmpSwingMode;
|
||||||
bool _tmpAwayMode = false;
|
bool _tmpAwayMode = false;
|
||||||
|
bool _tmpIsOff = false;
|
||||||
|
bool _tmpAuxHeat = false;
|
||||||
double _temperatureStep = 0.2;
|
double _temperatureStep = 0.2;
|
||||||
|
|
||||||
void _resetVars(ClimateEntity entity) {
|
void _resetVars(ClimateEntity entity) {
|
||||||
_tmpTemperature = entity.temperature;
|
_tmpTemperature = entity.temperature;
|
||||||
|
_tmpTargetHigh = entity.targetHigh;
|
||||||
|
_tmpTargetLow = entity.targetLow;
|
||||||
_tmpOperationMode = entity.operationMode;
|
_tmpOperationMode = entity.operationMode;
|
||||||
|
_tmpFanMode = entity.fanMode;
|
||||||
|
_tmpSwingMode = entity.swingMode;
|
||||||
_tmpAwayMode = entity.awayMode;
|
_tmpAwayMode = entity.awayMode;
|
||||||
|
_tmpIsOff = entity.isOff;
|
||||||
|
_tmpAuxHeat = entity.auxHeat;
|
||||||
|
|
||||||
_showPending = false;
|
_showPending = false;
|
||||||
_changedHere = false;
|
_changedHere = false;
|
||||||
}
|
}
|
||||||
@ -260,6 +273,26 @@ class _ClimateControlWidgetState extends State<ClimateControlWidget> {
|
|||||||
_setTemperature(entity);
|
_setTemperature(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _targetLowUp(ClimateEntity entity) {
|
||||||
|
_tmpTargetLow += _temperatureStep;
|
||||||
|
_setTargetTemp(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _targetLowDown(ClimateEntity entity) {
|
||||||
|
_tmpTargetLow -= _temperatureStep;
|
||||||
|
_setTargetTemp(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _targetHighUp(ClimateEntity entity) {
|
||||||
|
_tmpTargetHigh += _temperatureStep;
|
||||||
|
_setTargetTemp(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _targetHighDown(ClimateEntity entity) {
|
||||||
|
_tmpTargetHigh -= _temperatureStep;
|
||||||
|
_setTargetTemp(entity);
|
||||||
|
}
|
||||||
|
|
||||||
void _setTemperature(ClimateEntity entity) {
|
void _setTemperature(ClimateEntity entity) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_tmpTemperature = double.parse(_tmpTemperature.toStringAsFixed(1));
|
_tmpTemperature = double.parse(_tmpTemperature.toStringAsFixed(1));
|
||||||
@ -269,6 +302,16 @@ class _ClimateControlWidgetState extends State<ClimateControlWidget> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _setTargetTemp(ClimateEntity entity) {
|
||||||
|
setState(() {
|
||||||
|
_tmpTargetLow = double.parse(_tmpTargetLow.toStringAsFixed(1));
|
||||||
|
_tmpTargetHigh = double.parse(_tmpTargetHigh.toStringAsFixed(1));
|
||||||
|
_changedHere = true;
|
||||||
|
eventBus.fire(new ServiceCallEvent(entity.domain, "set_temperature", entity.entityId,{"target_temp_high": "${_tmpTargetHigh.toStringAsFixed(1)}", "target_temp_low": "${_tmpTargetLow.toStringAsFixed(1)}"}));
|
||||||
|
_resetStateTimer(entity);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void _setOperationMode(ClimateEntity entity, value) {
|
void _setOperationMode(ClimateEntity entity, value) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_tmpOperationMode = value;
|
_tmpOperationMode = value;
|
||||||
@ -278,6 +321,24 @@ class _ClimateControlWidgetState extends State<ClimateControlWidget> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _setSwingMode(ClimateEntity entity, value) {
|
||||||
|
setState(() {
|
||||||
|
_tmpSwingMode = value;
|
||||||
|
_changedHere = true;
|
||||||
|
eventBus.fire(new ServiceCallEvent(entity.domain, "set_swing_mode", entity.entityId,{"swing_mode": "$_tmpSwingMode"}));
|
||||||
|
_resetStateTimer(entity);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _setFanMode(ClimateEntity entity, value) {
|
||||||
|
setState(() {
|
||||||
|
_tmpFanMode = value;
|
||||||
|
_changedHere = true;
|
||||||
|
eventBus.fire(new ServiceCallEvent(entity.domain, "set_fan_mode", entity.entityId,{"fan_mode": "$_tmpFanMode"}));
|
||||||
|
_resetStateTimer(entity);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void _setAwayMode(ClimateEntity entity, value) {
|
void _setAwayMode(ClimateEntity entity, value) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_tmpAwayMode = value;
|
_tmpAwayMode = value;
|
||||||
@ -287,6 +348,24 @@ class _ClimateControlWidgetState extends State<ClimateControlWidget> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _setOnOf(ClimateEntity entity, value) {
|
||||||
|
setState(() {
|
||||||
|
_tmpIsOff = !value;
|
||||||
|
_changedHere = true;
|
||||||
|
eventBus.fire(new ServiceCallEvent(entity.domain, "${_tmpIsOff ? 'turn_off' : 'turn_on'}", entity.entityId, null));
|
||||||
|
_resetStateTimer(entity);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _setAuxHeat(ClimateEntity entity, value) {
|
||||||
|
setState(() {
|
||||||
|
_tmpAuxHeat = value;
|
||||||
|
_changedHere = true;
|
||||||
|
eventBus.fire(new ServiceCallEvent(entity.domain, "set_aux_heat", entity.entityId, {"aux_heat": "$_tmpAuxHeat"}));
|
||||||
|
_resetStateTimer(entity);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void _resetStateTimer(ClimateEntity entity) {
|
void _resetStateTimer(ClimateEntity entity) {
|
||||||
if (_resetTimer!=null) {
|
if (_resetTimer!=null) {
|
||||||
_resetTimer.cancel();
|
_resetTimer.cancel();
|
||||||
@ -313,36 +392,92 @@ class _ClimateControlWidgetState extends State<ClimateControlWidget> {
|
|||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Text("Target temperature for ${_tmpOperationMode != 'off' ? _tmpOperationMode : ''}", style: TextStyle(
|
_buildOnOffControl(entity),
|
||||||
fontSize: entity.stateFontSize
|
_buildTemperatureControls(entity),
|
||||||
)),
|
_buildOperationControl(entity),
|
||||||
Row(
|
_buildFanControl(entity),
|
||||||
children: <Widget>[
|
_buildSwingControl(entity),
|
||||||
Expanded(
|
_buildAwayModeControl(entity),
|
||||||
child: Text(
|
_buildAuxHeatControl(entity)
|
||||||
"$_tmpTemperature",
|
],
|
||||||
style: TextStyle(
|
),
|
||||||
fontSize: entity.largeFontSize,
|
);
|
||||||
color: _showPending ? Colors.red : Colors.black
|
}
|
||||||
),
|
|
||||||
),
|
Widget _buildAwayModeControl(ClimateEntity entity) {
|
||||||
|
if (entity.supportAwayMode) {
|
||||||
|
return Row(
|
||||||
|
children: <Widget>[
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
"Away mode",
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: entity.stateFontSize
|
||||||
),
|
),
|
||||||
Column(
|
),
|
||||||
children: <Widget>[
|
|
||||||
IconButton(
|
|
||||||
icon: Icon(Icons.keyboard_arrow_up),
|
|
||||||
iconSize: 30.0,
|
|
||||||
onPressed: () => _temperatureUp(entity),
|
|
||||||
),
|
|
||||||
IconButton(
|
|
||||||
icon: Icon(Icons.keyboard_arrow_down),
|
|
||||||
iconSize: 30.0,
|
|
||||||
onPressed: () => _temperatureDown(entity),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
|
Switch(
|
||||||
|
onChanged: (value) => _setAwayMode(entity, value),
|
||||||
|
value: _tmpAwayMode,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return Container(height: 0.0, width: 0.0,);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildOnOffControl(ClimateEntity entity) {
|
||||||
|
if (entity.supportOnOff) {
|
||||||
|
return Row(
|
||||||
|
children: <Widget>[
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
"On / Off",
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: entity.stateFontSize
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Switch(
|
||||||
|
onChanged: (value) => _setOnOf(entity, value),
|
||||||
|
value: !_tmpIsOff,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return Container(height: 0.0, width: 0.0,);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildAuxHeatControl(ClimateEntity entity) {
|
||||||
|
if (entity.supportAwayMode) {
|
||||||
|
return Row(
|
||||||
|
children: <Widget>[
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
"Aux heat",
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: entity.stateFontSize
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Switch(
|
||||||
|
onChanged: (value) => _setAuxHeat(entity, value),
|
||||||
|
value: _tmpAuxHeat,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return Container(height: 0.0, width: 0.0,);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildOperationControl(ClimateEntity entity) {
|
||||||
|
if (entity.supportOperationMode) {
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: <Widget>[
|
||||||
Text("Operation", style: TextStyle(
|
Text("Operation", style: TextStyle(
|
||||||
fontSize: entity.stateFontSize
|
fontSize: entity.stateFontSize
|
||||||
)),
|
)),
|
||||||
@ -361,27 +496,167 @@ class _ClimateControlWidgetState extends State<ClimateControlWidget> {
|
|||||||
}).toList(),
|
}).toList(),
|
||||||
onChanged: (mode) => _setOperationMode(entity, mode),
|
onChanged: (mode) => _setOperationMode(entity, mode),
|
||||||
),
|
),
|
||||||
Padding(
|
Container(height: entity.rowPadding,)
|
||||||
padding: EdgeInsets.only(top: entity.rowPadding),
|
|
||||||
child: Row(
|
|
||||||
children: <Widget>[
|
|
||||||
Expanded(
|
|
||||||
child: Text(
|
|
||||||
"Away mode",
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: entity.stateFontSize
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Switch(
|
|
||||||
onChanged: (value) => _setAwayMode(entity, value),
|
|
||||||
value: _tmpAwayMode,
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
],
|
||||||
),
|
);
|
||||||
|
} else {
|
||||||
|
return Container(height: 0.0, width: 0.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildFanControl(ClimateEntity entity) {
|
||||||
|
if (entity.supportFanMode) {
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: <Widget>[
|
||||||
|
Text("Fan mode", style: TextStyle(
|
||||||
|
fontSize: entity.stateFontSize
|
||||||
|
)),
|
||||||
|
DropdownButton<String>(
|
||||||
|
value: "$_tmpFanMode",
|
||||||
|
iconSize: 30.0,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: entity.largeFontSize,
|
||||||
|
color: Colors.black,
|
||||||
|
),
|
||||||
|
items: entity.fanList.map((String value) {
|
||||||
|
return new DropdownMenuItem<String>(
|
||||||
|
value: value,
|
||||||
|
child: new Text(value),
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
onChanged: (mode) => _setFanMode(entity, mode),
|
||||||
|
),
|
||||||
|
Container(height: entity.rowPadding,)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return Container(height: 0.0, width: 0.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildSwingControl(ClimateEntity entity) {
|
||||||
|
if (entity.supportSwingMode) {
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: <Widget>[
|
||||||
|
Text("Swing mode", style: TextStyle(
|
||||||
|
fontSize: entity.stateFontSize
|
||||||
|
)),
|
||||||
|
DropdownButton<String>(
|
||||||
|
value: "$_tmpSwingMode",
|
||||||
|
iconSize: 30.0,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: entity.largeFontSize,
|
||||||
|
color: Colors.black,
|
||||||
|
),
|
||||||
|
items: entity.swingList.map((String value) {
|
||||||
|
return new DropdownMenuItem<String>(
|
||||||
|
value: value,
|
||||||
|
child: new Text(value),
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
onChanged: (mode) => _setSwingMode(entity, mode),
|
||||||
|
),
|
||||||
|
Container(height: entity.rowPadding,)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return Container(height: 0.0, width: 0.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildTemperatureControls(ClimateEntity entity) {
|
||||||
|
List<Widget> result = [];
|
||||||
|
if (entity.supportTargetTemperature) {
|
||||||
|
result.addAll(<Widget>[
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
"$_tmpTemperature",
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: entity.largeFontSize,
|
||||||
|
color: _showPending ? Colors.red : Colors.black
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Column(
|
||||||
|
children: <Widget>[
|
||||||
|
IconButton(
|
||||||
|
icon: Icon(Icons.keyboard_arrow_up),
|
||||||
|
iconSize: 30.0,
|
||||||
|
onPressed: () => _temperatureUp(entity),
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
icon: Icon(Icons.keyboard_arrow_down),
|
||||||
|
iconSize: 30.0,
|
||||||
|
onPressed: () => _temperatureDown(entity),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
)
|
||||||
|
]);
|
||||||
|
} else if (entity.supportTargetTemperatureHigh && entity.supportTargetTemperatureLow) {
|
||||||
|
result.addAll(<Widget>[
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
"$_tmpTargetLow",
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: entity.largeFontSize,
|
||||||
|
color: _showPending ? Colors.red : Colors.black
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Column(
|
||||||
|
children: <Widget>[
|
||||||
|
IconButton(
|
||||||
|
icon: Icon(Icons.keyboard_arrow_up),
|
||||||
|
iconSize: 30.0,
|
||||||
|
onPressed: () => _targetLowUp(entity),
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
icon: Icon(Icons.keyboard_arrow_down),
|
||||||
|
iconSize: 30.0,
|
||||||
|
onPressed: () => _targetLowDown(entity),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Container(width: 20.0,),
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
"$_tmpTargetHigh",
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: entity.largeFontSize,
|
||||||
|
color: _showPending ? Colors.red : Colors.black
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Column(
|
||||||
|
children: <Widget>[
|
||||||
|
IconButton(
|
||||||
|
icon: Icon(Icons.keyboard_arrow_up),
|
||||||
|
iconSize: 30.0,
|
||||||
|
onPressed: () => _targetHighUp(entity),
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
icon: Icon(Icons.keyboard_arrow_down),
|
||||||
|
iconSize: 30.0,
|
||||||
|
onPressed: () => _targetHighDown(entity),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
)
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
result.add(Text("Unsupported temperature controls =("));
|
||||||
|
}
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: <Widget>[
|
||||||
|
Text("Target temperature", style: TextStyle(
|
||||||
|
fontSize: entity.stateFontSize
|
||||||
|
)),
|
||||||
|
Row(
|
||||||
|
children: result,
|
||||||
|
)
|
||||||
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -350,7 +350,7 @@ class ClimateStateWidget extends StatelessWidget {
|
|||||||
fontSize: entityModel.entity.stateFontSize,
|
fontSize: entityModel.entity.stateFontSize,
|
||||||
)),
|
)),
|
||||||
Text(
|
Text(
|
||||||
entity.temperature!= null ? " ${entity.temperature}" : " ${entity.targetLow} - ${entity.targetHigh}",
|
entity.supportTargetTemperature ? " ${entity.temperature}" : " ${entity.targetLow} - ${entity.targetHigh}",
|
||||||
textAlign: TextAlign.right,
|
textAlign: TextAlign.right,
|
||||||
style: new TextStyle(
|
style: new TextStyle(
|
||||||
fontSize: entityModel.entity.stateFontSize,
|
fontSize: entityModel.entity.stateFontSize,
|
||||||
|
@ -192,7 +192,7 @@ class HomeAssistant {
|
|||||||
|
|
||||||
_handleMessage(String message) {
|
_handleMessage(String message) {
|
||||||
var data = json.decode(message);
|
var data = json.decode(message);
|
||||||
TheLogger.log("Debug","[Received] => $data");
|
TheLogger.log("Debug","[Received] => ${data['type']}");
|
||||||
if (data["type"] == "auth_required") {
|
if (data["type"] == "auth_required") {
|
||||||
_sendAuthMessageRaw('{"type": "auth","$_authType": "$_password"}');
|
_sendAuthMessageRaw('{"type": "auth","$_authType": "$_password"}');
|
||||||
} else if (data["type"] == "auth_ok") {
|
} else if (data["type"] == "auth_ok") {
|
||||||
|
Reference in New Issue
Block a user