Hello there
I don’t know if it is me. but my code can’t import the webthings library the right way
my code:
from webthing import Property, Value, WebThingServer, SingleThing, Thing
import time
def make_thing():
print("hey1")
light = Thing(
'urn:dev:ops:my-lamp-1234',
'My Lamp',
['OnOffSwitch', 'Light'],
'A web connected lamp'
)
print("hey2")
light.add_property(
Property(
light,
'on',
Value(True),
metadata={
'@type': 'OnOffProperty',
'title': 'On/Off',
'type': 'boolean',
'description': 'Whether the lamp is turned on',
}))
print("hey3")
light.add_property(
Property(
light,
'brightness',
Value(50, v),
metadata={
'@type': 'BrightnessProperty',
'title': 'Brightness',
'type': 'number',
'description': 'The level of light from 0-100',
'minimum': 0,
'maximum': 100,
'unit': 'percent',
}))
make_thing()
# If adding more than one thing, use MultipleThings() with a name.
# In the single thing case, the thing's name will be broadcast.
server = WebThingServer(SingleThing(light), port=8888)
print("hey")
try:
server.start()
except KeyboardInterrupt:
server.stop()
The error code:
Traceback (most recent call last): File "wt.py", line 1, in <module> from webthing import Property, Value, WebThingServer, SingleThing, Thing File "/usr/local/lib/python3.5/dist-packages/webthing/__init__.py", line 6, in <module> from .property import Property File "/usr/local/lib/python3.5/dist-packages/webthing/property.py", line 4, in <module> from jsonschema import validate File "/usr/local/lib/python3.5/dist-packages/jsonschema/__init__.py", line 56 raise AttributeError(f"module {__name__} has no attribute {name}") ^ SyntaxError: invalid syntax