You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 7, 2021. It is now read-only.
Copy file name to clipboardExpand all lines: README.rst
+4-6Lines changed: 4 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -63,16 +63,15 @@ First we create a new Thing:
63
63
64
64
Now we can add the required properties.
65
65
66
-
The ``on`` property reports and sets the on/off state of the light. We can pass `writeproperty` argument pointing to a method to actually turn the light on/off. For our purposes, we just want to log the new state if the light is switched on/off.
66
+
The on property reports and sets the on/off state of the light. For this, we need to have a Value object which holds the actual state and also a method to turn the light on/off. For our purposes, we just want to log the new state if the light is switched on/off.
67
67
68
68
.. code:: python
69
69
70
70
light.add_property(
71
71
Property(
72
72
light,
73
73
'on',
74
-
initial_value=True,
75
-
writeproperty=lambdav: print('On-State is now', v),
74
+
Value(True, None, lambdax: print(x)),
76
75
metadata={
77
76
'@type': 'OnOffProperty',
78
77
'title': 'On/Off',
@@ -88,8 +87,7 @@ The ``brightness`` property reports the brightness level of the light and sets t
88
87
Property(
89
88
light,
90
89
'brightness',
91
-
initial_value=50,
92
-
writeproperty=lambdav: print('Brightness is now', v),
90
+
Value(50, None, lambdax: print(x)),
93
91
metadata={
94
92
'@type': 'BrightnessProperty',
95
93
'title': 'Brightness',
@@ -144,7 +142,7 @@ Contrary to the light, the value cannot be set via an API call, as it wouldn't m
0 commit comments