oven-lab / tuya_cloud_map_extractor

Tuya cloud vacuum map extractor for Home Assistant
MIT License
29 stars 6 forks source link

Possibly add live location/path direct from vacuum #32

Open backcountrymountains opened 9 months ago

backcountrymountains commented 9 months ago

Unfortunately, the path information retrieved from the tuya cloud doesn't update frequently with my vacuum. For example, the last time I ran the vacuum it only updated the path once during the whole 40 minute cleaning time.

However, my vacuum does barf out a constant stream of base64-encoded json-formatted data while it's running. One part of that data is the vacuum's position:

{{(state_attr('vacuum.downstairs_vacuum','sensor')| base64_decode)}}
{%set pos = (state_attr('vacuum.downstairs_vacuum','sensor')| base64_decode) | from_json %}
{{pos['data']['pos'] }}

returns a constantly updating stream of data:

{"data":{"pos":[-619,-4395]},"infoType":20001}
[-619, -4395]
...
{"data":{"phi":-3141,"pos":[-2224,-3225]},"infoType":20001}
[-2224, -3225]

I don't know what "phi" is.

I don't know if other vacuums also send out this data, but I was wondering how hard it would be to use the data directly sent from the vacuum to draw the path and mark the vacuum's current location on the map.

I've also noticed that when I look at the map in the tuya app, it seems to load path sections sequentially in order to display the combined most recent total path. That is, it loads the path from one area, and then another area, and another on top of the map. Perhaps, my vacuum has a weird way of storing the path data in the tuya cloud and this integration is only downloading the initial path segment and not subsequent path segments?

oven-lab commented 9 months ago

This seems to be the way tuya cloud works. It only stores the latest couple hundred points. Then you have to get the rest locally.

Most vacuums seems to have a pathComm or rawComm DP, but I haven't tried getting the data from my vacuum yet.

You seem to be lucky, and your vacuum already spits this data out without having to ask for it. I could add a service or something of the kind to add position points through home assistant, until I get the whole localtuya protocol up and running. Perhaps during the coming week.

backcountrymountains commented 9 months ago

Cool!

I was poking around iot.tuya.com and I noticed that there are Get Map File List and Get Downlaod Link of Map commands that allow downloading of maps but I'm not sure how they are different from the Get Link of Real-Time Map. One file I downloaded is an lz4 compressed bin file that has some json but then also some other data that might be lz4 compressed as well?

                                                               ./CleanInfoBak.json                                                                                 0000644 0000000 0000000 00000000632 14567672261 013101  0                                                                                                    ustar   root                            root                                                                                                                                                                                                                   {
    "AllClean" : 
    {
        "AllArea" : 665,
        "AllTime" : 40728,
        "CleanCounts" : 17,
        "MopArea" : 0,
        "MopCounts" : 0,
        "SweepArea" : 665,
        "SweepCounts" : 17
    },
    "Goods" : 
    {
        "battery" : 40728,
        "dustBox" : 40728,
        "filter" : 40728,
        "mainBrush" : 40728,
        "mop" : 0,
        "motor" : 40728,
        "sensors" : 40728,
        "sideBrush" : 40728
    },
    "SingleClean" : 
    {
        "CleanArea" : 45,
        "CleanTime" : 3558
    }
}
                                                                                                      ./FindChgerEndPose                                                                                  0000644 0000000 0000000 00000000031 14567672261 012755  0                                                                                                    ustar   root                            root                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   ./FoundIrSignalPose                                                                                 0000644 0000000 0000000 00000002541 14567672261 013211  0                                                                                                    ustar   root                            root                                                                                                                                                                                                                   9          à»À   @E¤÷¿    ™À   à*dÀ    ð8À   `EBÀ    jÀ    þ†À   àï{@   `êi
À    ò^ö¿    IÀ   €V
À   @ù­ü¿    ²@¿   àRÁÀ   à–&÷¿   àI1@   €Ö
À   `ûÚÀ   à
^À     ¹À   @7   À    ·Ì @    êÀ    ˆ›À    $Mà?   àC^
À    ˜Ø
À    þ@   €wéÀ   À%Õ
À   `› À   €’«À   àìßÀ    ™áÀ    º À   à¸îÀ    7ÖÀ    ÀˆÀ   `¶òÀ   `ªÜÀ   ÀFÀ   `TÃÀ   `9 À    ëÀ    ½À    `?Ž?   €ÜdÀ   €ã¢À    ŠûÀ    9ù À   À¨^À    ØF®?   @T+
À   À@À   ` À    ‹‹À   €T`À   €“Tâ?   ÀÖæÀ   €QÀ   €qç?   àö-À    S À   €Lâí?   @Öœ
À   àNk À    t À   à£ÓÀ   @ÀƒÀ    ³      @   @pqÀ   @ƒÀ   àšøÀ    ¼W@    2ÙÀ    £aú¿    ÉÉÀ   à‘–÷¿    u‘¿   @yvÀ   @u›À   `Y…@   €©ê¿   `ç‡à?   @úRø¿   àÚ°À    jHö¿    t.À   Àn@    ð’À   @îïó¿   ` h
À   @Jö¿    VwÀ       ó
À   àïÍ À    Ð-Ÿ¿   `P™
À   `kÖ À    b”?   à! À   €òôÀ   @Qú÷?    ÜoÀ    P“ü¿   @ÂÂÀ   àÒ}À   ÀKÿ¿   @tÉÀ   €ÎêÀ   `AÇÀ   @Þ#À    ÈÄÀ   €oŽÀ   @   þ?    žÓÀ   `o6À   €Åþä?   `…:À   `àÿ¿   €7´î?   `E
À   à
g À    D
    À   àjµÀ   àiÀ   @yíÀ   €\óÀ    hXÀ   À)Úó?   àzÍ À    ÍêÀ    H¹¤¿   €g®À     ¬À   àÖ À   àµÀ    ð©À    ç À   @\z
À   `ö·À    à€¿   `î‚À    2« À   À<[À   @o¸À   €zÆ À   `ÏúÀ   `¸3À   `¹Å À   ÀÝïÀ    «‹À   `\ÛÀ   à9 À   àæ À   àÄí
À    ØõÀ   `MÀ    Wì
À   €©ýÀ    ΘÀ    €À   `þÀ    >Ö À    À    ZøÀ    ÍÀ   @   R
À    ›$@                                                                                                                                                               ./Grid.map                                                                                          0000644 0000000 0000000 00001257377 14567672261 011343  0                                                                                                    ustar   root                            root                                                                                                                                                                                                                                   ÍÌL=Ê'»9¨8Ç9–Ô9d¼á9·Ið9Çÿ9ö!:Yè:s?:“0$:£Å.:-   ::jF:KÉR:†^`:œÓn:ô6~:íK‡:L:AJ™:*£:`¬­:ÇÛ¸:QÃÄ:ÍnÑ:ÇêÞ:›Dí:}Šü:Äe;è;3@;»";*x,;7;n]C;ÈìO;'J];¦‚k;0¤z;Ê^…;Fï;å—;‡½ ;—
«;¶;£±Á;†Î;´OÛ;ßZé;‚Jø;q<•ˆ<²ƒ<N<i7)<”4<é{?<®K<‰¤X< kf<‘u<N‚<%‘Š<ÑW“<ªœ<  ¦<¤±< ;¼<ïÈ<†¤Ô<‡úá<4 ð<X!ÿ<*…=ô=ä=V\"=.d,=I7=¢AB=~'N=s½Z=`h=lv=}‚=ìUŠ=hž’=ˆ[›=u’¤=iH®=­‚¸=•FÃ=t™Î=š€Ú=Gç=© ô=æñ >Ç'>O´>¯™>öÙ>w(>vr1>ÂÍ:>ŠD> ¨N>(Y>d>¹Po>‘÷z>|ƒ>±²‰>f>X£–>^>°B¤>NO«>²>×¹>MÁ>`àÈ>ŽÐ>‡RØ>g*à>ðè>Sð>© ø>   ?«ÿ?Wý?÷?Íê?½Ö? ¹?я?Y?s#?2¿&?YX*?¨Þ-?üP1?T®4?Íõ7?¨&;?C@>?BA?Ò+D? ýF?ܵI?øUL?~ÝN?LQ?b£S?@âU?ƒ    X?“Z?ì\?ö]?†Ã_?ê{a?×c?í¯d?Ñ,f?-—g?ªïh?ó6j?²mk?”l?3¬m?Bµn?`°o?)žp?:q?)Tr?ˆs?æÛs?̏t?½9u?;Úu?¾qv?¿ w?®‡w?öx?þ~x?-ðx?ÛZy?h¿y?(z?lwz?€Ëz?°{?Ae{?w«{?í{?Æ+|?Tf|?o|?GÑ|?}?ö/}?"[}?¿ƒ}?ò©}?ÝÍ}?¥ï}?k~?K-~?aI~?Èc~?ž|~?õ“~?æ©~?†¾~?èÑ~?"ä~?Cõ~?\?}?¶"?0?¤<?pH?ˆS?õ]?Ág?ôp?›y?º?]‰?‹?I—?ž?‘£?)©?j®?[³?þ·?Z¼?rÀ?LÄ?èÇ?MË?~Î?~Ñ?OÔ?õÖ?pÙ?ÅÛ?÷Ý?à?øá?Éã?å?ç?šè?KV ³¾ÄÉÍÐÓÕ×ÙÚÜÝßàáâãäåæçèéêêëìííîïïðññòòóôôõõöö÷÷øùùúúûûüüýýþþÿÿ