WebThingsIO / gateway

WebThings Gateway - a self-hosted web application for monitoring and controlling a building over the web
http://webthings.io/gateway
Mozilla Public License 2.0
2.61k stars 339 forks source link

Consider logging validation failures in Things.setThingProperty #3175

Open jamesmf opened 21 hours ago

jamesmf commented 21 hours ago

I found when setting the value of a zigbee light through the UI, it often took two or more attempts to succeed.

I checked the network tab and it looked like the PUT requests were firing with valid-looking payloads ({"level":75.8} failed while {"level":42.5} worked fine a moment later). So I checked the logs and it seems to be failing here.

I'm wondering if it's sensible to log the specific validation errors to help troubleshoot when these issues come up.

I tried a resend with {"level":75.8} and it failed again, but then an edit-and-resend of {"level":75.9} succeeded. Weirdly many (but not all!) values ending in .8 failed.

Thanks for continued work on a great project!

benfrancis commented 12 hours ago

Hi @jamesmf, thanks for reporting. What a strange bug!

I'm not able to reproduce this on the master branch with a Virtual Dimmable Light web thing, which suggests it could either already be fixed on the master branch (where the set property payloads look a bit different), or be specific to the Zigbee add-on or even the specific model of device. If the latter was the case though it would be odd for the error to happen at the gateway model layer rather than in the Zigbee add-on process, so it's also possible the problem is intermittent.

So that I can try to reproduce this it would be helpful if you could provide more details:

Thank you.

jamesmf commented 11 hours ago

I'm seeing 400 error reponses with Invalid property value. They show up in the logs of the gateway and they are the response to the PUT in my browser. The logs don't have any other detail, just timestamps and 400 - Invalid property value

I am using v1.1.0 with automatic updates enabled, last update Jan 05 2023.

I'm running on a pi 3 and I'm honestly a bit fuzzy on what version I would have flashed, I followed a guide a very very long time ago before the documentation on using docker was great. I should probably refresh the whole setup at some point but I don't yet have full confidence I know how to mount the zigbee device properly. If I were using docker I am guessing I could much more confidently just edit the file to add the log myself 🤔

I bought the usb zigbee dongle a long time ago, but if you have thoughts on the best way to get whatever detail would be helpful, I'll get those too, sorry!