@@ -872,6 +872,155 @@ class MideaQuirkFactory {
872872 ) ;
873873 }
874874 } ) ;
875+ case MideaQuirkFactory . KNOWN_QUIRKS . CLEAN_ROUTE :
876+ return new Quirk ( {
877+ id : id ,
878+ title : "Clean Route" ,
879+ description : "Trade speed for thoroughness and vice-versa. \"Quick\" is one-time-use and will automatically unset itself afterwards." ,
880+ options : [ "Quick" , "Normal" , "Deep" ] ,
881+ getter : async ( ) => {
882+ const packet = new MSmartPacket ( {
883+ messageType : MSmartPacket . MESSAGE_TYPE . ACTION ,
884+ payload : MSmartPacket . buildPayload ( MSmartConst . ACTION . GET_CLEANING_SETTINGS_1 )
885+ } ) ;
886+
887+ const response = await this . robot . sendCommand ( packet . toHexString ( ) ) ;
888+ const parsedResponse = BEightParser . PARSE ( response ) ;
889+
890+ if ( parsedResponse instanceof MSmartCleaningSettings1DTO ) {
891+ switch ( parsedResponse . route_type ) {
892+ case 0 :
893+ return "Quick" ;
894+ case 1 :
895+ return "Normal" ;
896+ case 2 :
897+ return "Deep" ;
898+ }
899+ } else {
900+ throw new Error ( "Invalid response from robot" ) ;
901+ }
902+ } ,
903+ setter : async ( value ) => {
904+ let val ;
905+
906+ switch ( value ) {
907+ case "Quick" :
908+ val = 0 ;
909+ break ;
910+ case "Normal" :
911+ val = 1 ;
912+ break ;
913+ case "Deep" :
914+ val = 2 ;
915+ break ;
916+ default :
917+ throw new Error ( `Invalid clean route value: ${ value } ` ) ;
918+ }
919+
920+ const packet = new MSmartPacket ( {
921+ messageType : MSmartPacket . MESSAGE_TYPE . SETTING ,
922+ payload : MSmartPacket . buildPayload (
923+ MSmartConst . SETTING . SET_CLEANING_SETTINGS_1 ,
924+ Buffer . from ( [
925+ 0x00 ,
926+ val
927+ ] )
928+ )
929+ } ) ;
930+
931+ await this . robot . sendCommand ( packet . toHexString ( ) ) ;
932+ }
933+ } ) ;
934+ case MideaQuirkFactory . KNOWN_QUIRKS . THRESHOLD_RECOGNITION :
935+ return new Quirk ( {
936+ id : id ,
937+ title : "Threshold Recognition" ,
938+ description : "Detect thresholds using the AI camera and act accordingly." ,
939+ options : [ "off" , "on" ] ,
940+ getter : async ( ) => {
941+ const response = await this . robot . sendCommand ( new MSmartPacket ( {
942+ messageType : MSmartPacket . MESSAGE_TYPE . ACTION ,
943+ payload : MSmartPacket . buildPayload ( MSmartConst . ACTION . GET_STATUS )
944+ } ) . toHexString ( ) ) ;
945+ const parsedResponse = BEightParser . PARSE ( response ) ;
946+
947+ if ( parsedResponse instanceof MSmartStatusDTO ) {
948+ return parsedResponse . threshold_recognition_switch ? "on" : "off" ;
949+ } else {
950+ throw new Error ( "Invalid response from robot" ) ;
951+ }
952+ } ,
953+ setter : async ( value ) => {
954+ let val ;
955+
956+ switch ( value ) {
957+ case "off" :
958+ val = 0 ;
959+ break ;
960+ case "on" :
961+ val = 1 ;
962+ break ;
963+ default :
964+ throw new Error ( `Invalid threshold recognition value: ${ value } ` ) ;
965+ }
966+
967+ await this . robot . sendCommand ( new MSmartPacket ( {
968+ messageType : MSmartPacket . MESSAGE_TYPE . SETTING ,
969+ payload : MSmartPacket . buildPayload (
970+ MSmartConst . SETTING . SET_VARIOUS_TOGGLES ,
971+ Buffer . from ( [
972+ 0x3A ,
973+ val
974+ ] )
975+ )
976+ } ) . toHexString ( ) ) ;
977+ }
978+ } ) ;
979+ case MideaQuirkFactory . KNOWN_QUIRKS . BRIDGE_BOOST :
980+ return new Quirk ( {
981+ id : id ,
982+ title : "Threshold Boost" ,
983+ description : "Automatically increase suction when over or near a threshold. Like carpet mode but for thresholds." ,
984+ options : [ "off" , "on" ] ,
985+ getter : async ( ) => {
986+ const response = await this . robot . sendCommand ( new MSmartPacket ( {
987+ messageType : MSmartPacket . MESSAGE_TYPE . ACTION ,
988+ payload : MSmartPacket . buildPayload ( MSmartConst . ACTION . GET_STATUS )
989+ } ) . toHexString ( ) ) ;
990+ const parsedResponse = BEightParser . PARSE ( response ) ;
991+
992+ if ( parsedResponse instanceof MSmartStatusDTO ) {
993+ return parsedResponse . bridge_boost_switch ? "on" : "off" ;
994+ } else {
995+ throw new Error ( "Invalid response from robot" ) ;
996+ }
997+ } ,
998+ setter : async ( value ) => {
999+ let val ;
1000+
1001+ switch ( value ) {
1002+ case "off" :
1003+ val = 0 ;
1004+ break ;
1005+ case "on" :
1006+ val = 1 ;
1007+ break ;
1008+ default :
1009+ throw new Error ( `Invalid bridge boost value: ${ value } ` ) ;
1010+ }
1011+
1012+ await this . robot . sendCommand ( new MSmartPacket ( {
1013+ messageType : MSmartPacket . MESSAGE_TYPE . SETTING ,
1014+ payload : MSmartPacket . buildPayload (
1015+ MSmartConst . SETTING . SET_VARIOUS_TOGGLES ,
1016+ Buffer . from ( [
1017+ 0x1C ,
1018+ val
1019+ ] )
1020+ )
1021+ } ) . toHexString ( ) ) ;
1022+ }
1023+ } ) ;
8751024 default :
8761025 throw new Error ( `There's no quirk with id ${ id } ` ) ;
8771026 }
@@ -894,6 +1043,9 @@ MideaQuirkFactory.KNOWN_QUIRKS = {
8941043 MOP_DOCK_WATER_USAGE : "c0ccbdfe-c942-41ac-a770-ad1efdc98f8b" ,
8951044 MOP_DRYING_TIME : "46a8fac4-ced5-469d-8435-234942f1d0f1" ,
8961045 MOP_DOCK_SELF_CLEANING_FREQUENCY : "8aa6f147-dbcc-44f6-a9f9-2a7f4fb59c7e" ,
1046+ CLEAN_ROUTE : "985704dc-2853-4dca-a018-265e7684111c" ,
1047+ THRESHOLD_RECOGNITION : "2fa33876-f5ad-444d-9084-d51eb7be4670" ,
1048+ BRIDGE_BOOST : "17d539ff-51d3-49be-8b9e-29aa1e9c8d39" ,
8971049} ;
8981050
8991051module . exports = MideaQuirkFactory ;
0 commit comments