@@ -43,7 +43,7 @@ public enum Renderer {YAFARAY, SUNFLOW}
43
43
public enum Quality {HIGH , LOW }
44
44
public enum ImageFormat {PNG , JPEG }
45
45
public enum EntityDisplayType {BADGE , ICON , LABEL , NONE }
46
- public enum EntityTapAction {MORE_INFO , NONE , TOGGLE }
46
+ public enum EntityAction {MORE_INFO , NONE , TOGGLE }
47
47
48
48
private static final String TRANSPARENT_IMAGE_NAME = "transparent" ;
49
49
@@ -59,6 +59,8 @@ public enum EntityTapAction {MORE_INFO, NONE, TOGGLE}
59
59
private static final String CONTROLLER_USE_EXISTING_RENDERS = "useExistingRenders" ;
60
60
private static final String CONTROLLER_ENTITY_DISPLAY_TYPE = "displayType" ;
61
61
private static final String CONTROLLER_ENTITY_TAP_ACTION = "tapAction" ;
62
+ private static final String CONTROLLER_ENTITY_DOUBLE_TAP_ACTION = "doubleTapAction" ;
63
+ private static final String CONTROLLER_ENTITY_HOLD_ACTION = "holdAction" ;
62
64
private static final String CONTROLLER_ENTITY_ALWAYS_ON = "alwaysOn" ;
63
65
private static final String CONTROLLER_ENTITY_IS_RGB = "isRgb" ;
64
66
@@ -92,16 +94,20 @@ private class Entity {
92
94
public String name ;
93
95
public Point2d position ;
94
96
public EntityDisplayType displayType ;
95
- public EntityTapAction tapAction ;
97
+ public EntityAction tapAction ;
98
+ public EntityAction doubleTapAction ;
99
+ public EntityAction holdAction ;
96
100
public String title ;
97
101
public boolean alwaysOn ;
98
102
public boolean isRgb ;
99
103
100
- public Entity (String name , Point2d position , EntityDisplayType defaultDisplayType , EntityTapAction defaultTapAction , String title ) {
104
+ public Entity (String name , Point2d position , EntityDisplayType defaultDisplayType , EntityAction defaultTapAction , String title ) {
101
105
this .name = name ;
102
106
this .position = position ;
103
107
this .displayType = EntityDisplayType .valueOf (settings .get (name + "." + CONTROLLER_ENTITY_DISPLAY_TYPE , defaultDisplayType .name ()));
104
- this .tapAction = EntityTapAction .valueOf (settings .get (name + "." + CONTROLLER_ENTITY_TAP_ACTION , defaultTapAction .name ()));
108
+ this .tapAction = EntityAction .valueOf (settings .get (name + "." + CONTROLLER_ENTITY_TAP_ACTION , defaultTapAction .name ()));
109
+ this .doubleTapAction = EntityAction .valueOf (settings .get (name + "." + CONTROLLER_ENTITY_DOUBLE_TAP_ACTION , EntityAction .NONE .name ()));
110
+ this .holdAction = EntityAction .valueOf (settings .get (name + "." + CONTROLLER_ENTITY_HOLD_ACTION , EntityAction .MORE_INFO .name ()));
105
111
this .title = title ;
106
112
this .alwaysOn = settings .getBoolean (name + "." + CONTROLLER_ENTITY_ALWAYS_ON , false );
107
113
this .isRgb = settings .getBoolean (name + "." + CONTROLLER_ENTITY_IS_RGB , false );
@@ -273,15 +279,33 @@ public void setEntityDisplayType(String entityName, EntityDisplayType displayTyp
273
279
settings .set (entityName + "." + CONTROLLER_ENTITY_DISPLAY_TYPE , displayType .name ());
274
280
}
275
281
276
- public EntityTapAction getEntityTapAction (String entityName ) {
282
+ public EntityAction getEntityTapAction (String entityName ) {
277
283
return homeAssistantEntities .get (entityName ).tapAction ;
278
284
}
279
285
280
- public void setEntityTapAction (String entityName , EntityTapAction tapAction ) {
286
+ public void setEntityTapAction (String entityName , EntityAction tapAction ) {
281
287
homeAssistantEntities .get (entityName ).tapAction = tapAction ;
282
288
settings .set (entityName + "." + CONTROLLER_ENTITY_TAP_ACTION , tapAction .name ());
283
289
}
284
290
291
+ public EntityAction getEntityDoubleTapAction (String entityName ) {
292
+ return homeAssistantEntities .get (entityName ).doubleTapAction ;
293
+ }
294
+
295
+ public void setEntityDoubleTapAction (String entityName , EntityAction doubleTapAction ) {
296
+ homeAssistantEntities .get (entityName ).doubleTapAction = doubleTapAction ;
297
+ settings .set (entityName + "." + CONTROLLER_ENTITY_DOUBLE_TAP_ACTION , doubleTapAction .name ());
298
+ }
299
+
300
+ public EntityAction getEntityHoldAction (String entityName ) {
301
+ return homeAssistantEntities .get (entityName ).holdAction ;
302
+ }
303
+
304
+ public void setEntityHoldAction (String entityName , EntityAction holdAction ) {
305
+ homeAssistantEntities .get (entityName ).holdAction = holdAction ;
306
+ settings .set (entityName + "." + CONTROLLER_ENTITY_HOLD_ACTION , holdAction .name ());
307
+ }
308
+
285
309
public boolean getEntityAlwaysOn (String entityName ) {
286
310
return homeAssistantEntities .get (entityName ).alwaysOn ;
287
311
}
@@ -311,6 +335,8 @@ public void resetEntitySettings(String entityName) {
311
335
boolean oldIsRgb = homeAssistantEntities .get (entityName ).isRgb ;
312
336
settings .set (entityName + "." + CONTROLLER_ENTITY_DISPLAY_TYPE , null );
313
337
settings .set (entityName + "." + CONTROLLER_ENTITY_TAP_ACTION , null );
338
+ settings .set (entityName + "." + CONTROLLER_ENTITY_DOUBLE_TAP_ACTION , null );
339
+ settings .set (entityName + "." + CONTROLLER_ENTITY_HOLD_ACTION , null );
314
340
settings .set (entityName + "." + CONTROLLER_ENTITY_ALWAYS_ON , null );
315
341
settings .set (entityName + "." + CONTROLLER_ENTITY_IS_RGB , null );
316
342
int oldNumberOfTotaleRenders = getNumberOfTotalRenders ();
@@ -801,10 +827,10 @@ private String generateEntityYaml(Entity entity) {
801
827
put (EntityDisplayType .ICON , "state-icon" );
802
828
put (EntityDisplayType .LABEL , "state-label" );
803
829
}};
804
- final Map <EntityTapAction , String > entityTapActionToYamlString = new HashMap <EntityTapAction , String >() {{
805
- put (EntityTapAction .MORE_INFO , "more-info" );
806
- put (EntityTapAction .NONE , "none" );
807
- put (EntityTapAction .TOGGLE , "toggle" );
830
+ final Map <EntityAction , String > entityTapActionToYamlString = new HashMap <EntityAction , String >() {{
831
+ put (EntityAction .MORE_INFO , "more-info" );
832
+ put (EntityAction .NONE , "none" );
833
+ put (EntityAction .TOGGLE , "toggle" );
808
834
}};
809
835
810
836
if (entity .displayType == EntityDisplayType .NONE || entity .alwaysOn )
@@ -821,10 +847,15 @@ private String generateEntityYaml(Entity entity) {
821
847
" text-align: center\n " +
822
848
" background-color: rgba(255, 255, 255, 0.3)\n " +
823
849
" tap_action:\n " +
850
+ " action: %s\n " +
851
+ " double_tap_action:\n " +
852
+ " action: %s\n " +
853
+ " hold_action:\n " +
824
854
" action: %s\n " ,
825
855
entityDisplayTypeToYamlString .get (entity .displayType ), entity .name , entity .title ,
826
856
100.0 * (entity .position .y / renderHeight ), 100.0 * (entity .position .x / renderWidth ),
827
- entityTapActionToYamlString .get (entity .tapAction ));
857
+ entityTapActionToYamlString .get (entity .tapAction ), entityTapActionToYamlString .get (entity .doubleTapAction ),
858
+ entityTapActionToYamlString .get (entity .holdAction ));
828
859
829
860
return yaml ;
830
861
}
@@ -855,7 +886,7 @@ private void generateLightEntities(Map<String, Entity> homeAssistantEntities) {
855
886
lightsCenter .scale (1.0 / lightsList .size ());
856
887
857
888
String name = lightsList .get (0 ).getName ();
858
- homeAssistantEntities .put (name , new Entity (name , lightsCenter , EntityDisplayType .ICON , EntityTapAction .TOGGLE ,
889
+ homeAssistantEntities .put (name , new Entity (name , lightsCenter , EntityDisplayType .ICON , EntityAction .TOGGLE ,
859
890
lightsList .get (0 ).getDescription ()));
860
891
}
861
892
}
@@ -884,7 +915,7 @@ private void generateSensorEntities(Map<String, Entity> homeAssistantEntities) {
884
915
885
916
homeAssistantEntities .put (name , new Entity (name , location ,
886
917
name .startsWith ("sensor." ) ? EntityDisplayType .LABEL : EntityDisplayType .ICON ,
887
- isHomeAssistantEntityActionable (piece .getName ()) ? EntityTapAction .TOGGLE : EntityTapAction .MORE_INFO ,
918
+ isHomeAssistantEntityActionable (piece .getName ()) ? EntityAction .TOGGLE : EntityAction .MORE_INFO ,
888
919
piece .getDescription ()));
889
920
}
890
921
}
0 commit comments