@@ -1007,6 +1007,76 @@ describe('Extension: HomeAssistant', () => {
1007
1007
} ) ;
1008
1008
} ) ;
1009
1009
1010
+ it ( 'Should discover dual cover devices' , async ( ) => {
1011
+ const payload_left = {
1012
+ availability : [
1013
+ {
1014
+ topic : 'zigbee2mqtt/bridge/state' ,
1015
+ value_template : '{{ value_json.state }}' ,
1016
+ } ,
1017
+ ] ,
1018
+ command_topic : 'zigbee2mqtt/0xa4c138018cf95021/left/set' ,
1019
+ device : {
1020
+ identifiers : [ 'zigbee2mqtt_0xa4c138018cf95021' ] ,
1021
+ manufacturer : 'Lonsonho' ,
1022
+ model : 'Dual curtain/blind module (TS130F_dual)' ,
1023
+ name : '0xa4c138018cf95021' ,
1024
+ via_device : 'zigbee2mqtt_bridge_0x00124b00120144ae' ,
1025
+ } ,
1026
+ name : 'Left' ,
1027
+ object_id : '0xa4c138018cf95021_left' ,
1028
+ origin : origin ,
1029
+ position_template : '{{ value_json.position }}' ,
1030
+ position_topic : 'zigbee2mqtt/0xa4c138018cf95021/left' ,
1031
+ set_position_template : '{ "position_left": {{ position }} }' ,
1032
+ set_position_topic : 'zigbee2mqtt/0xa4c138018cf95021/left/set' ,
1033
+ state_closing : 'DOWN' ,
1034
+ state_opening : 'UP' ,
1035
+ state_stopped : 'STOP' ,
1036
+ state_topic : 'zigbee2mqtt/0xa4c138018cf95021/left' ,
1037
+ unique_id : '0xa4c138018cf95021_cover_left_zigbee2mqtt' ,
1038
+ value_template : '{% if "moving" in value_json and value_json.moving %} {{ value_json.moving }} {% else %} STOP {% endif %}' ,
1039
+ } ;
1040
+ const payload_right = {
1041
+ availability : [
1042
+ {
1043
+ topic : 'zigbee2mqtt/bridge/state' ,
1044
+ value_template : '{{ value_json.state }}' ,
1045
+ } ,
1046
+ ] ,
1047
+ command_topic : 'zigbee2mqtt/0xa4c138018cf95021/right/set' ,
1048
+ device : {
1049
+ identifiers : [ 'zigbee2mqtt_0xa4c138018cf95021' ] ,
1050
+ manufacturer : 'Lonsonho' ,
1051
+ model : 'Dual curtain/blind module (TS130F_dual)' ,
1052
+ name : '0xa4c138018cf95021' ,
1053
+ via_device : 'zigbee2mqtt_bridge_0x00124b00120144ae' ,
1054
+ } ,
1055
+ name : 'Right' ,
1056
+ object_id : '0xa4c138018cf95021_right' ,
1057
+ origin : origin ,
1058
+ position_template : '{{ value_json.position }}' ,
1059
+ position_topic : 'zigbee2mqtt/0xa4c138018cf95021/right' ,
1060
+ set_position_template : '{ "position_right": {{ position }} }' ,
1061
+ set_position_topic : 'zigbee2mqtt/0xa4c138018cf95021/right/set' ,
1062
+ state_closing : 'DOWN' ,
1063
+ state_opening : 'UP' ,
1064
+ state_stopped : 'STOP' ,
1065
+ state_topic : 'zigbee2mqtt/0xa4c138018cf95021/right' ,
1066
+ unique_id : '0xa4c138018cf95021_cover_right_zigbee2mqtt' ,
1067
+ value_template : '{% if "moving" in value_json and value_json.moving %} {{ value_json.moving }} {% else %} STOP {% endif %}' ,
1068
+ } ;
1069
+
1070
+ expect ( mockMQTT . publishAsync ) . toHaveBeenCalledWith ( 'homeassistant/cover/0xa4c138018cf95021/cover_left/config' , stringify ( payload_left ) , {
1071
+ retain : true ,
1072
+ qos : 1 ,
1073
+ } ) ;
1074
+ expect ( mockMQTT . publishAsync ) . toHaveBeenCalledWith ( 'homeassistant/cover/0xa4c138018cf95021/cover_right/config' , stringify ( payload_right ) , {
1075
+ retain : true ,
1076
+ qos : 1 ,
1077
+ } ) ;
1078
+ } ) ;
1079
+
1010
1080
it ( 'Should discover devices with custom homeassistant.discovery_topic' , async ( ) => {
1011
1081
settings . set ( [ 'homeassistant' ] , { discovery_topic : 'my_custom_discovery_topic' } ) ;
1012
1082
await resetExtension ( ) ;
0 commit comments