smarthomej / addons

SmartHome/J addons for openHAB
Eclipse Public License 2.0
59 stars 23 forks source link

[Tuya] failed to parse JSON: java.lang.IllegalStateException #498

Closed kgoderis closed 1 year ago

kgoderis commented 1 year ago

I get a lot of these in my logs :

2023-06-18 22:07:26.140 [WARN ] [.internal.local.handlers.TuyaDecoder] - bffdf3209d379d2fc7nknm/192.168.0.163:6668 failed to parse JSON: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $ 2023-06-18 22:08:57.429 [WARN ] [.internal.local.handlers.TuyaDecoder] - bffdf3209d379d2fc7nknm/192.168.0.163:6668 failed to parse JSON: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $ 2023-06-18 22:08:57.887 [WARN ] [.internal.local.handlers.TuyaDecoder] - bffdf3209d379d2fc7nknm/192.168.0.163:6668 failed to parse JSON: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $ 2023-06-18 22:08:58.481 [WARN ] [.internal.local.handlers.TuyaDecoder] - bffdf3209d379d2fc7nknm/192.168.0.163:6668 failed to parse JSON: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $ 2023-06-18 22:08:58.495 [WARN ] [.internal.local.handlers.TuyaDecoder] - bffdf3209d379d2fc7nknm/192.168.0.163:6668 failed to parse JSON: com.google.gson.stream.MalformedJsonException: Expected value at line 1 column 1 path $ 2023-06-18 22:09:00.009 [WARN ] [.internal.local.handlers.TuyaDecoder] - bffdf3209d379d2fc7nknm/192.168.0.163:6668 failed to parse JSON: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $ 2023-06-18 22:09:00.842 [WARN ] [.internal.local.handlers.TuyaDecoder] - bffdf3209d379d2fc7nknm/192.168.0.163:6668 failed to parse JSON: com.google.gson.stream.MalformedJsonException: Expected value at line 1 column 1 path $ 2023-06-18 22:09:01.249 [WARN ] [.internal.local.handlers.TuyaDecoder] - bffdf3209d379d2fc7nknm/192.168.0.163:6668 failed to parse JSON: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $ 2023-06-19 07:10:26.246 [WARN ] [.internal.local.handlers.TuyaDecoder] - bffdf3209d379d2fc7nknm/192.168.0.163:6668 failed to parse JSON: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $ 2023-06-19 08:18:50.330 [WARN ] [.internal.local.handlers.TuyaDecoder] - bfb5d7cf6a3156ad2fugbf/192.168.0.254:6668 failed to parse JSON: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $ 2023-06-19 08:19:05.364 [WARN ] [.internal.local.handlers.TuyaDecoder] - bfb5d7cf6a3156ad2fugbf/192.168.0.254:6668 failed to parse JSON: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $

kgoderis commented 1 year ago

@J-N-K I added some TRACEing, this is what I get around each one of these errors:

2023-06-19 12:28:56.427 [TRACE] [.internal.local.handlers.TuyaDecoder] - udpListener: Received encoded '000055AA00000000000000130000009C0000000023D01E5FEF56833314CEF60FB086ED33B92C00227845D8C5E12B4EBED191F118EC84AC0EAC8DC500438B6A136A0132F4A6D835DC018E863334372A8760FDC9F37256F992EF0BB3C9946F6CA8E2E148532E0DBC9A92C3317286EBF238BE5797866AADEAFDEC3D2F5901C84C888D5DCDA7B04A82876F98E334B84197EFF80B263D7A23E3B2249F5ADF48A714F851AAF4396505EC750000AA55' 2023-06-19 12:28:56.427 [TRACE] [.internal.local.handlers.TuyaDecoder] - udpListener: Decoded raw payload: 7B226970223A223139322E3136382E302E323534222C2267774964223A2262666235643763663661333135366164326675676266222C22616374697665223A322C2261626C696C7479223A302C22656E6372797074223A747275652C2270726F647563744B6579223A22636A7361346B3774716270757971336C222C2276657273696F6E223A22332E33227D04040404 2023-06-19 12:28:56.427 [DEBUG] [.internal.local.handlers.TuyaDecoder] - udpListener: Received MessageWrapper{commandType=UDP_NEW, content='DiscoveryMessage{ip='192.168.0.254', deviceId='bfb5d7cf6a3156ad2fugbf', active=2, ability=0, mode=0, encrypt=true, productKey='cjsa4k7tqbpuyq3l', version='3.3', token= true, wf_cfg=true}'} 2023-06-19 12:28:56.429 [TRACE] [.internal.local.handlers.TuyaDecoder] - udpListener: Received encoded '000055AA00000000000000130000009C0000000023D01E5FEF56833314CEF60FB086ED33B92C00227845D8C5E12B4EBED191F118EC84AC0EAC8DC500438B6A136A0132F4A6D835DC018E863334372A8760FDC9F37256F992EF0BB3C9946F6CA8E2E148532E0DBC9A92C3317286EBF238BE5797866AADEAFDEC3D2F5901C84C888D5DCDA7B04A82876F98E334B84197EFF80B263D7A23E3B2249F5ADF48A714F851AAF4396505EC750000AA55' 2023-06-19 12:28:56.429 [TRACE] [.internal.local.handlers.TuyaDecoder] - udpListener: Decoded raw payload: 7B226970223A223139322E3136382E302E323534222C2267774964223A2262666235643763663661333135366164326675676266222C22616374697665223A322C2261626C696C7479223A302C22656E6372797074223A747275652C2270726F647563744B6579223A22636A7361346B3774716270757971336C222C2276657273696F6E223A22332E33227D04040404 2023-06-19 12:28:56.429 [DEBUG] [.internal.local.handlers.TuyaDecoder] - udpListener: Received MessageWrapper{commandType=UDP_NEW, content='DiscoveryMessage{ip='192.168.0.254', deviceId='bfb5d7cf6a3156ad2fugbf', active=2, ability=0, mode=0, encrypt=true, productKey='cjsa4k7tqbpuyq3l', version='3.3', token= true, wf_cfg=true}'} 2023-06-19 12:28:56.470 [TRACE] [.internal.local.handlers.TuyaDecoder] - bfb5d7cf6a3156ad2fugbf/192.168.0.254:6668: Received encoded '000055AA00000000000000080000003B00000000332E33000000000000CBE0000000013953AF09E917BBA8B0BA481F5B0C7C74F5795BD84F6B7C79BAE62266A9DC8310F1F4C5980000AA55' 2023-06-19 12:28:56.470 [TRACE] [.internal.local.handlers.TuyaDecoder] - bfb5d7cf6a3156ad2fugbf/192.168.0.254:6668: Decoded raw payload: 7E27403F557CA2A93B8F267AF9CD54EA5589F76BDD1F9C02245571D390EF11EA 2023-06-19 12:28:56.470 [WARN ] [.internal.local.handlers.TuyaDecoder] - bfb5d7cf6a3156ad2fugbf/192.168.0.254:6668 failed to parse JSON: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $ 2023-06-19 12:28:56.517 [TRACE] [.internal.local.handlers.TuyaDecoder] - bfb5d7cf6a3156ad2fugbf/192.168.0.254:6668: Received encoded '000055AA00000000000000080000004B00000000332E33000000000000CBE1000000018A6C600EB6DE39CF6F86D1FECE78210B1ED5D3EAA2D060763459B5454A1C211747BD6D06BA18BDE5B27C4FD3BCD932A3B2FB730F0000AA55' 2023-06-19 12:28:56.517 [TRACE] [.internal.local.handlers.TuyaDecoder] - bfb5d7cf6a3156ad2fugbf/192.168.0.254:6668: Decoded raw payload: 4638705892D3875980C0FEDC120D7F5A5FBC2D2ED42963A00E7A1495E530AABB7BC5B92E784F8F022B3844B95C46643C 2023-06-19 12:28:56.518 [WARN ] [.internal.local.handlers.TuyaDecoder] - bfb5d7cf6a3156ad2fugbf/192.168.0.254:6668 failed to parse JSON: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $

Hope this can help you

J-N-K commented 1 year ago

The decoded payload is just garbage: ~'@?U|¢©;&zùÍTêU‰÷kÝœ$UqӐïê. That looks like a wrong decryption key. Did you add the thing from discovery? Try deleting and re-discovering it.

kgoderis commented 1 year ago

@J-N-K No, not from discovery, from a .things file. This was after a re-install of openHAB, but I retained all logins/keys from before e.g. from the tuya project portal. I thought it was a single device, but I now see 2 different IP addresses in the logs, so it must be something else. That being said, both are flagged ONLINE in the runtime. Maybe an exception can be used and in such case put them OFFLINE with a CONFIGURATION_ERROR ?