Closed sogaani closed 6 years ago
gateway-addon-python
assumes that setting a property value won't fail. Maybe that's invalid, though. The relevant bits of code are:
Related wot script spec https://w3c.github.io/wot-scripting-api/#the-writeproperty-method If we follow wot spec, maybe python addon should raise exception on failing setProperty?
We don't really follow that spec at all, so I wouldn't go by that. However, I'm not opposed to wrapping the set_value()
call in a try/except. It would match the node library, then.
What are you suggesting we do on reject/exception, though? The node library sends back a property change notification.
My suggestion is that If we catch reject/exception, addon-proxy send a error message "setProperty is failed" to the Gateway, and the Gateway return a error response for 'PUT /things/:thingId/:properties/:propertyName'.
I kind of like having the property change notification, that way the UI gets updated back to the current value.
I kind of like having the property change notification, that way the UI gets updated back to the current value.
Does this comment mean that send propertyChange message on websocket and response errors on REST API when setProperty
via REST API is failed?
I think it would be appropriate to send back the current value as part of an error message in both cases, rather than having a property notification AND an error message. Unfortunately, our WoT spec doesn't yet define what to do when errors occur.
I'd prefer to return fails message like action. Because, I want to use setProperty for checking that the device is online.
I figured out this issue on google actions App review. They have a test case which checks that the google actions App return the device state.
The test case is run like so:
Thing does not have any state like online or unplugged. So, I'm using this issue check the device is online.