Skip to content
HN On Hacker News ↗

Teaching Home Assistant to Talk to My Litter Box

▲ 34 points • 14 comments • by allidoisvim • 3d ago • HN discussion ↗

Pangram verdict · v3.3

We believe that this text is a mix of AI and human-written content.

82 %

AI likelihood · overall

AI
18% human-written 82% AI-generated
SEGMENTS · HUMAN 5 of 23
SEGMENTS · AI 17 of 23
WORD COUNT 1,032
PEAK AI % 100% · §3
Analyzed
Nov 20
backend: pangram/v3.3
Segments scanned
23 windows
avg 45 words each
Distribution
18 / 82%
human / AI fraction
Verdict
AI
Pangram v3.3

Article text · 1,032 words · 23 segments analyzed

Human AI-generated
§1 Human · 0%

Maisie likes to touch the litter box while it is running.

§2 AI · 100%

I would prefer that she find something else to do during that time. My idea was to bring the litter box into Home Assistant, add some buttons, and eventually use presence sensors to start a cleaning cycle when she is in another room and distracted.

§3 AI · 100%

There are probably many more automations I will come up with once I have that working. First, I needed a way to talk to the box. The phone app already knew how to do everything I needed.

§4 AI · 100%

I started by watching its traffic with Wireshark and inspecting HTTP requests with HTTP Toolkit, then decompiled the Android app to understand the parts I could not reproduce from the traffic alone.

§5 AI · 100%

This turned into two related projects.

§6 AI · 100%

I needed to reproduce the signed HTTP requests used to access account and device data, then rebuild the binary messages used to operate the box over MQTT. Recreating the HTTP Requests The HTTP traffic exposed devices on the account, configuration, waste drawer levels, and records of litter box visits.

§7 AI · 100%

I could also see how authentication worked.

§8 AI · 100%

The app logs in to obtain a token, then includes that token in the Authorization header on later requests. My first attempts to reproduce the requests returned 401 Unauthorized. Copying the endpoints and headers from a capture had not been enough. A 401 did not identify exactly which part of my reproduction was wrong, so I went back to comparing the app’s requests. The X-UBT-Sign header kept changing. I could not work out its algorithm just by looking at the captured values. To generate my own requests, I needed to see how the app created it.

§9 Human · 3%

I used JADX to decompile the Android APK, then searched the recovered source for the header name and familiar backend strings: grep -R -n -E 'X-UBT-Sign|catbox-server|airrobo-home' \ furrytail_decompiled/sources The header name gave me a useful place to start in the decompiled code.

§10 AI · 100%

It appears in sources/com/ubtrobot/infrastructure/a0.java, an obfuscated class whose retained metadata identifies it as UrcsSignInterceptor from HttpInterceptors.kt.

§11 AI · 100%

The interceptor builds the signature and attaches it to outgoing HTTP requests. Its hashing helper, a.b.t, calls MessageDigest.getInstance("MD5"). The decompiled code shows the final header being assembled and added to the request.

§12 Human · 0%

From sources/com/ubtrobot/infrastructure/a0.java: long jLongValue = lValueOf != null ? lValueOf.longValue() : System.currentTimeMillis(); String appKey = this.f16792b; kotlin.jvm.internal.g.f(appKey, "appKey"); kotlin.jvm.internal.g.f(deviceId, "deviceId"); String string = UUID.randomUUID().toString(); kotlin.jvm.internal.g.e(string, "randomUUID().toString()"); String strSubstring = string.substring(0, 10); kotlin.jvm.internal.g.e(strSubstring, "this as java.lang.String…ing(startIndex, endIndex)"); String str2 = a.b.t(jLongValue + appKey + strSubstring + deviceId) + ' ' + jLongValue + ' ' + strSubstring + " v2"; w.a aVar2 = new w.a(wVar); aVar2.c("X-UBT-AppId", str); aVar2.c("X-UBT-DeviceId", deviceId); aVar2.c("X-UBT-Sign", str2); The key is used for request signing.

§13 AI · 100%

The Python implementation concatenates a timestamp in milliseconds, the app key, a nonce, and a client device ID, then calculates an MD5 digest: timestamp = str(int(time.time() * 1000)) nonce = uuid.uuid4().hex[:10] raw = timestamp + app_key + nonce + device_id digest = hashlib.md5(raw.encode()).hexdigest() signature = f"{digest} {timestamp} {nonce} v2" The order and formatting matter because the server needs to reproduce the same value. This is also why copying a single captured header would only get me so far. My client needed to generate a new signature for each request. Finding the algorithm still left the application settings to sort out. During implementation, a mismatched client configuration produced an “illegal client” response. I followed the app’s regional bootstrap flow. In CountryViewModel, it configures a bootstrap server using an app ID and key embedded in the APK.

§14 AI · 100%

The interface in sources/jb/a.java declares a request to /catbox-server/app/areaMap. That request is signed too.

§15 AI · 100%

The embedded bootstrap key signs the region-discovery request, whose response supplies the regional app ID, app key, and API URL. The regional key then signs login and normal API requests. Following that chain let me obtain the matching US settings for my client.

§16 Human · 0%

From sources/com/ubtrobot/airpet/account/area/CountryViewModel.java: v.a aVar = new v.a(); String strM = t.m(application.getApplicationContext()); g.e(strM, "getDeviceId(application.applicationContext)"); aVar.a(new a0("970010044", "<redacted app key>", strM)); aVar.a(sVar); aVar.f26434d.add(m.a()); v vVar = new v(aVar); z.b bVar = new z.b(); bVar.f23318b = vVar; bVar.c("https://jdm-oversea.airrobo-home.com"); From sources/jb/a.java: public interface a { @oh.f("/catbox-server/app/areaMap") Object a(zf.c<?

§17 Mixed · 35%

super n<ServerResponse<List<AreaRegionUrl>>>> cVar); } There were a few similarly named fields to keep straight: X-UBT-AppId identifies the application configuration and needs to match the app key.

§18 AI · 100%

X-UBT-DeviceId is a stable client/app-install identifier.

§19 AI · 100%

It is also included in the signature calculation; it is not the litter box’s serial number.

§20 AI · 100%

Authorization contains the account token returned by login.

§21 AI · 100%

X-UBT-Sign contains the freshly generated request signature, even when the account token is still valid. The login request separately hashes the account password with MD5. Its response includes token.token, the value to send in Authorization, and token.expireAt, the expiration time in milliseconds. I wrapped this in a small asynchronous HTTP client that reuses the token, logs in again shortly before expiration, and retries once after a 401. The token structure is visible in my captured successful login response. I’ve redacted the credentials and omitted the account details. From furrytail_login_response.json: { "token": { "token": "<redacted>", "expireAt": 1784094899156, "refreshToken": "<redacted>" } } With that in place, I could turn the vendor’s responses into useful API endpoints like /device/waste and /device/summary. That gave me the data for a dashboard. Making a cleaning button required another layer of work. Finding the Command Path The next clue came from something I did not see in Wireshark. When I pressed Clean in the app, there was no new HTTP request corresponding to the action. For a moment, I wondered whether the app was talking to the box over Bluetooth. But I could also operate the box remotely, so Bluetooth would not explain the whole command path. Looking more closely at the app’s startup requests, I found /v1/ubtechinc-im-manager/im/login. Its response included mqttUserName, mqttPassword, clientId, pubTopic, and subTopic. That gave me another protocol to investigate, plus the credentials and topics needed to connect.

§22 Human · 0%

From sources/gf/m.java: @o("/v1/ubtechinc-im-manager/im/login") mh.b<UrcsResponse<MqttInfoBean>> c(@oh.a com.google.gson.m mVar, @oh.i("authorization") String str); From sources/com/ubtrobot/urcs/connection/MqttInfoBean.java: public class MqttInfoBean { public String clientId; public String mqttPassword; public String mqttUserName; public String pubTopic; public String subTopic; public String uid; } After connecting to the broker as a subscriber, I pressed Clean again.

§23 AI · 100%

This time I could see a message arrive.