Skip to content
This repository was archived by the owner on Jun 7, 2021. It is now read-only.

Commit ee87a01

Browse files
committed
Fixed readme examples
1 parent cba68c1 commit ee87a01

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

README.rst

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,15 @@ First we create a new Thing:
6363
6464
Now we can add the required properties.
6565

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.
6767

6868
.. code:: python
6969
7070
light.add_property(
7171
Property(
7272
light,
7373
'on',
74-
initial_value=True,
75-
writeproperty=lambda v: print('On-State is now', v),
74+
Value(True, None, lambda x: print(x)),
7675
metadata={
7776
'@type': 'OnOffProperty',
7877
'title': 'On/Off',
@@ -88,8 +87,7 @@ The ``brightness`` property reports the brightness level of the light and sets t
8887
Property(
8988
light,
9089
'brightness',
91-
initial_value=50,
92-
writeproperty=lambda v: print('Brightness is now', v),
90+
Value(50, None, lambda x: print(x)),
9391
metadata={
9492
'@type': 'BrightnessProperty',
9593
'title': 'Brightness',
@@ -144,7 +142,7 @@ Contrary to the light, the value cannot be set via an API call, as it wouldn't m
144142
Property(
145143
sensor,
146144
'level',
147-
readproperty=self.read_from_gpio,
145+
Value(None, self.read_from_gpio, None),
148146
metadata={
149147
'@type': 'LevelProperty',
150148
'title': 'Humidity',

0 commit comments

Comments
 (0)