{"record":{"id":"2c8952602341761f","repo":"AlexxIT/go2rtc","slug":"failed-to-subscribe-to-lowpower-topic-w","errorCode":null,"errorMessage":"failed to subscribe to lowPower topic: %w","messagePattern":"failed to subscribe to lowPower topic: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/tuya/mqtt.go","lineNumber":199,"sourceCode":"\t\tb, err := hex.DecodeString(hexStr[i : i+2])\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to decode hex: %w\", err)\n\t\t}\n\t\tpayload[i/2] = b[0]\n\t}\n\n\t// Publish to wake-up topic: m/w/{deviceId}\n\twakeUpTopic := fmt.Sprintf(\"m/w/%s\", c.deviceId)\n\ttoken := c.client.Publish(wakeUpTopic, 1, false, payload)\n\tif token.Wait() && token.Error() != nil {\n\t\treturn fmt.Errorf(\"failed to publish wake-up message: %w\", token.Error())\n\t}\n\n\t// Subscribe to lowPower topic to receive dps[149] status updates\n\t// (we don't wait for this signal - camera responds immediately)\n\tlowPowerTopic := fmt.Sprintf(\"smart/decrypt/in/%s\", c.deviceId)\n\tif token := c.client.Subscribe(lowPowerTopic, 1, c.onLowPowerMessage); token.Wait() && token.Error() != nil {\n\t\treturn fmt.Errorf(\"failed to subscribe to lowPower topic: %w\", token.Error())\n\t}\n\n\treturn nil\n}\n\nfunc (c *TuyaMqttClient) SendOffer(sdp string, streamResolution string, streamType int, isHEVC bool) error {\n\t// Map Skill StreamType to MQTT stream_type values\n\t// streamType comes from GetStreamType() and uses Skill StreamType values:\n\t// - mainStream = 2 (HD)\n\t// - substream = 4 (SD)\n\t//\n\t// But MQTT expects mapped stream_type values:\n\t// - mainStream (2) → stream_type: 0\n\t// - substream (4) → stream_type: 1\n\n\tmqttStreamType := streamType\n\tswitch streamType {\n\tcase 2:","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/AlexxIT/go2rtc/blob/c245815e75e2a5fd60b4290f12bfc04e55a984d3/pkg/tuya/mqtt.go#L181-L217","documentation":"WakeUp subscribes to the lowPower topic smart/decrypt/in/{deviceId} (QoS 1) so onLowPowerMessage can receive dps[149] status updates; a failure of that SUBSCRIBE token is wrapped in this error. The wake-up publish succeeded but the client cannot listen for the camera's response. Without the subscription, subsequent status updates are lost.","triggerScenarios":"client.Subscribe(lowPowerTopic,...) returns a non-nil token error: broker rejected the subscription (ACL/auth), the connection dropped between publish and subscribe, or the topic filter is invalid.","commonSituations":"Broker ACLs that deny wildcards or the decrypt topic, credentials lacking subscribe rights on the shared topic, or flaky connections to low-power camera MQTT brokers.","solutions":["Verify broker ACL/permissions allow SUBSCRIBE on smart/decrypt/in/{deviceId}","Check connection state before subscribing and reconnect if needed","Retry the subscribe with backoff; a transient disconnect usually resolves on reconnect","Confirm the deviceId is exact — a malformed topic can be rejected"],"exampleFix":"// before\nerr := client.WakeUp(deviceID)\n// after\nerr := client.WakeUp(deviceID)\nif err != nil && strings.Contains(err.Error(), \"subscribe to lowPower\") {\n    time.Sleep(time.Second)\n    err = client.WakeUp(deviceID)\n}","handlingStrategy":"retry","validationCode":"if deviceID == \"\" { return errors.New(\"empty deviceId prevents lowPower subscription\") }","typeGuard":null,"tryCatchPattern":"err := client.WakeUp(deviceID)\nif err != nil && strings.Contains(err.Error(), \"subscribe to lowPower\") {\n    time.Sleep(500 * time.Millisecond)\n    err = client.WakeUp(deviceID)\n}","preventionTips":["Grant subscribe ACLs for smart/decrypt/in topics on the broker","Subscribe-then-publish ordering where your broker requires it","Monitor Subscribe token errors in logs to detect ACL changes"],"tags":["go","mqtt","subscribe","network","tuya"],"backgroundTag":"http-request-failed","analyzedSha":"c245815e75e2a5fd60b4290f12bfc04e55a984d3","analyzedAt":"2026-09-07T11:47:02.965Z","contentChangedAt":"2026-09-07T11:47:02.965Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}