@ -35,4 +35,23 @@ class EntityTapAction {
|
|||||||
static const toggle = 'toggle';
|
static const toggle = 'toggle';
|
||||||
static const callService = 'call-service';
|
static const callService = 'call-service';
|
||||||
static const none = 'none';
|
static const none = 'none';
|
||||||
|
}
|
||||||
|
|
||||||
|
class CardType {
|
||||||
|
static const entities = "entities";
|
||||||
|
static const glance = "glance";
|
||||||
|
static const mediaControl = "media-control";
|
||||||
|
static const weatherForecast = "weather-forecast";
|
||||||
|
static const thermostat = "thermostat";
|
||||||
|
static const sensor = "sensor";
|
||||||
|
static const plantStatus = "plant-status";
|
||||||
|
static const pictureEntity = "picture-entity";
|
||||||
|
static const pictureElements = "picture-elements";
|
||||||
|
static const picture = "picture";
|
||||||
|
static const map = "map";
|
||||||
|
static const iframe = "iframe";
|
||||||
|
static const gauge = "gauge";
|
||||||
|
static const entityButton = "entity-button";
|
||||||
|
static const conditional = "conditional";
|
||||||
|
static const alarmPanel = "alarm-panel";
|
||||||
}
|
}
|
@ -11,7 +11,7 @@ class EntityIcon extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final entityModel = EntityModel.of(context);
|
final entityModel = EntityModel.of(context);
|
||||||
return GestureDetector(
|
return InkWell(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: padding,
|
padding: padding,
|
||||||
child: MaterialDesignIcons.createIconWidgetFromEntityData(
|
child: MaterialDesignIcons.createIconWidgetFromEntityData(
|
||||||
|
@ -13,7 +13,7 @@ class EntityName extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final entityModel = EntityModel.of(context);
|
final entityModel = EntityModel.of(context);
|
||||||
return GestureDetector(
|
return InkWell(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: padding,
|
padding: padding,
|
||||||
child: Text(
|
child: Text(
|
||||||
|
@ -13,7 +13,7 @@ class SimpleEntityState extends StatelessWidget {
|
|||||||
final entityModel = EntityModel.of(context);
|
final entityModel = EntityModel.of(context);
|
||||||
Widget result = Padding(
|
Widget result = Padding(
|
||||||
padding: padding,
|
padding: padding,
|
||||||
child: GestureDetector(
|
child: InkWell(
|
||||||
child: Text(
|
child: Text(
|
||||||
"${entityModel.entityWrapper.entity.state}${entityModel.entityWrapper.entity.unitOfMeasurement}",
|
"${entityModel.entityWrapper.entity.state}${entityModel.entityWrapper.entity.unitOfMeasurement}",
|
||||||
textAlign: textAlign,
|
textAlign: textAlign,
|
||||||
|
@ -447,13 +447,19 @@ class HomeAssistant {
|
|||||||
} else {
|
} else {
|
||||||
if (entities.isExist(rawEntity["entity"])) {
|
if (entities.isExist(rawEntity["entity"])) {
|
||||||
Entity e = entities.get(rawEntity["entity"]);
|
Entity e = entities.get(rawEntity["entity"]);
|
||||||
|
String tapAction = EntityTapAction.moreInfo;
|
||||||
|
String holdAction = EntityTapAction.none;
|
||||||
|
if (card.type == CardType.glance) {
|
||||||
|
tapAction = rawEntity["tap_action"] ?? EntityTapAction.moreInfo;
|
||||||
|
holdAction = rawEntity["hold_action"] ?? EntityTapAction.none;
|
||||||
|
}
|
||||||
card.entities.add(
|
card.entities.add(
|
||||||
EntityWrapper(
|
EntityWrapper(
|
||||||
entity: e,
|
entity: e,
|
||||||
displayName: rawEntity["name"],
|
displayName: rawEntity["name"],
|
||||||
icon: rawEntity["icon"],
|
icon: rawEntity["icon"],
|
||||||
tapAction: rawEntity["tap_action"] ?? EntityTapAction.moreInfo,
|
tapAction: tapAction,
|
||||||
holdAction: rawEntity["hold_action"] ?? EntityTapAction.none,
|
holdAction: holdAction,
|
||||||
tapActionService: rawEntity["service"],
|
tapActionService: rawEntity["service"],
|
||||||
tapActionServiceData: rawEntity["service_data"] ?? {"entity_id": e.entityId}
|
tapActionServiceData: rawEntity["service_data"] ?? {"entity_id": e.entityId}
|
||||||
)
|
)
|
||||||
|
@ -23,37 +23,37 @@ class HACard {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
|
||||||
case "entities": {
|
case CardType.entities: {
|
||||||
return EntitiesCardWidget(
|
return EntitiesCardWidget(
|
||||||
card: this,
|
card: this,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
case "glance": {
|
case CardType.glance: {
|
||||||
return GlanceCardWidget(
|
return GlanceCardWidget(
|
||||||
card: this,
|
card: this,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
case "media-control": {
|
case CardType.mediaControl: {
|
||||||
return MediaControlCardWidget(
|
return MediaControlCardWidget(
|
||||||
card: this,
|
card: this,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
case "weather-forecast":
|
case CardType.weatherForecast:
|
||||||
case "thermostat":
|
case CardType.thermostat:
|
||||||
case "sensor":
|
case CardType.sensor:
|
||||||
case "plant-status":
|
case CardType.plantStatus:
|
||||||
case "picture-entity":
|
case CardType.pictureEntity:
|
||||||
case "picture-elements":
|
case CardType.pictureElements:
|
||||||
case "picture":
|
case CardType.picture:
|
||||||
case "map":
|
case CardType.map:
|
||||||
case "iframe":
|
case CardType.iframe:
|
||||||
case "gauge":
|
case CardType.gauge:
|
||||||
case "entity-button":
|
case CardType.entityButton:
|
||||||
case "conditional":
|
case CardType.conditional:
|
||||||
case "alarm-panel": {
|
case CardType.alarmPanel: {
|
||||||
return UnsupportedCardWidget(
|
return UnsupportedCardWidget(
|
||||||
card: this,
|
card: this,
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user