Python Webthing Not Displaying Properly


(Kevin D) #1

So, I have a few RPi that I’ve been playing with. I built one as a gateway device, and a couple of others as individual Python-based webthings. It’s been rather interesting to figure out how to code my own webthing. So, here’s the issue: the webthing I built on one RPi works as expected. It’s showing the status of a “door” and allowing the trigger of a relay to open it. The second, however, does not work the same way. It doesn’t show the status of the door. I built them the same way (I wrote notes as I built the first one), and it’s using the exact same Python script. It’s almost as if they’re not speaking the same language. Can anyone identify something I may have missed when building the second one? Images and an initial GET from each webthing are below.

Working webthing:
Not-so-working webthing:

Working GET response:
{“links”: [{“href”: “/properties”, “rel”: “properties”}, {“href”: “/actions”, “rel”: “actions”}, {“href”: “/events”, “rel”: “events”}, {“href”: “ws://”, “rel”: “alternate”}], “actions”: {“trigger”: {“href”: “/actions/trigger”, “description”: “Trigger the gate to open”, “label”: “Push to Open”}}, “description”: “A web connected access gate”, “@type”: [“DoorSensor”], “properties”: {“state”: {"@type": “OpenProperty”, “href”: “/properties/state”, “type”: “boolean”, “description”: “Displays whether the gate is open”, “label”: “Open/Closed”}}, “events”: {}, “href”: “/”, “name”: “Gate”, “@context”: “”}

Not-so-working webthing GET response:
{“description”: “A web connected access gate”, “properties”: {“state”: {“label”: “Open/Closed”, “links”: [{“rel”: “property”, “href”: “/properties/state”}], “@type”: “OpenProperty”, “description”: “Displays whether the gate is open”, “type”: “boolean”}}, “@context”: “”, “@type”: [“DoorSensor”], “href”: “/”, “name”: “Gate”, “events”: {}, “links”: [{“rel”: “properties”, “href”: “/properties”}, {“rel”: “actions”, “href”: “/actions”}, {“rel”: “events”, “href”: “/events”}, {“rel”: “alternate”, “href”: “ws://”}], “actions”: {“trigger”: {“label”: “Push to Open”, “links”: [{“rel”: “action”, “href”: “/actions/trigger”}], “description”: “Trigger the gate to open”}}}

(Kevin D) #2

Just to add to that: at one point I though that it might have been something with the version of webthing that got installed. The first one was 0.9.2, and the second was 0.10.0. I actually went back in, uninstalled webthing, then reinstalled version 0.9.2 on the new device. Unfortunately, that didn’t resolve it. I checked the other requirements, and they’re all the same version, too. At this point, I have no idea what I’ve missed.

(Michael Stegeman) #3

v0.10.X changed some things in accordance with a spec change, but thing-url-adapter (Web Thing add-on) was just updated today to handle those changes. Could you make sure you have v0.2.6 of that add-on and try again?

(Kevin D) #4

I actually ended up finding the issue. It was related to version 0.10.0. I had two copies of webthing on that Pi. The context of the user the script was running in had anotehr copy. Once I properly removed all versions of 0.1.0, I was able to get 0.9.2 installed and the script started working properly again. I’ll have to test 0.10.0 on my next iteration, which I’m working on now. I’ll let you know when I get there.