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 }}
Repository navigation
Commit e754fdc
Browse filesBrowse the repository at this point in the historyBrowse files
<dt>This file is part of <strong>py-openzwave</strong> project <aclass="reference external" href="https://github.com/maartendamen/py-openzwave">https://github.com/maartendamen/py-openzwave</a>.</dt>
64
-
<dd><tableclass="first last docutils field-list" frame="void" rules="none">
<p><strong>py-openzwave</strong> is free software: you can redistribute it and/or modify
78
-
it under the terms of the GNU General Public License as published by
79
-
the Free Software Foundation, either version 3 of the License, or
80
-
(at your option) any later version.</p>
81
-
<p><strong>py-openzwave</strong> is distributed in the hope that it will be useful,
82
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
83
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
84
-
GNU General Public License for more details.
85
-
You should have received a copy of the GNU General Public License
86
-
along with py-openzwave. If not, see <aclass="reference external" href="http://www.gnu.org/licenses">http://www.gnu.org/licenses</a>.</p>
87
-
<dlclass="exception">
88
-
<dtid="openzwave.wrapper.ZWaveWrapperException">
89
-
<emclass="property">exception </em><ttclass="descclassname">openzwave.wrapper.</tt><ttclass="descname">ZWaveWrapperException</tt><big>(</big><em>value</em><big>)</big><aclass="headerlink" href="#openzwave.wrapper.ZWaveWrapperException" title="Permalink to this definition">¶</a></dt>
90
-
<dd><p>Exception class for ZWave Wrapper</p>
91
-
</dd></dl>
92
-
93
-
<dlclass="class">
94
-
<dtid="openzwave.wrapper.ZWaveValueNode">
95
-
<emclass="property">class </em><ttclass="descclassname">openzwave.wrapper.</tt><ttclass="descname">ZWaveValueNode</tt><big>(</big><em>home_id</em>, <em>node_id</em>, <em>value_data</em><big>)</big><aclass="headerlink" href="#openzwave.wrapper.ZWaveValueNode" title="Permalink to this definition">¶</a></dt>
96
-
<dd><p>Represents a single value for an OZW node element</p>
97
-
<dlclass="method">
98
-
<dtid="openzwave.wrapper.ZWaveValueNode.update">
99
-
<ttclass="descname">update</tt><big>(</big><em>args</em><big>)</big><aclass="headerlink" href="#openzwave.wrapper.ZWaveValueNode.update" title="Permalink to this definition">¶</a></dt>
100
-
<dd><p>Update node value from callback arguments</p>
101
-
</dd></dl>
102
-
103
-
</dd></dl>
104
-
105
-
<dlclass="class">
106
-
<dtid="openzwave.wrapper.ZWaveNode">
107
-
<emclass="property">class </em><ttclass="descclassname">openzwave.wrapper.</tt><ttclass="descname">ZWaveNode</tt><big>(</big><em>home_id</em>, <em>node_id</em><big>)</big><aclass="headerlink" href="#openzwave.wrapper.ZWaveNode" title="Permalink to this definition">¶</a></dt>
108
-
<dd><p>Represents a single device within the Z-Wave Network</p>
109
-
</dd></dl>
110
-
111
-
<dlclass="class">
112
-
<dtid="openzwave.wrapper.ZWaveWrapper">
113
-
<emclass="property">class </em><ttclass="descclassname">openzwave.wrapper.</tt><ttclass="descname">ZWaveWrapper</tt><big>(</big><em>device</em>, <em>config</em>, <em>log=None</em><big>)</big><aclass="headerlink" href="#openzwave.wrapper.ZWaveWrapper" title="Permalink to this definition">¶</a></dt>
114
-
<dd><p>The purpose of this wrapper is to eliminate some of the tedium of working with
115
-
the underlying API, which is extremely fine-grained.</p>
116
-
<p>Wrapper provides a single, cohesive set of python objects representing the
117
-
current state of the underlying ZWave network. It is kept in sync with OZW and
118
-
the network via callback hooks.</p>
119
-
<p>Note: This version only handles a single Driver/Controller. Modifications will
120
-
be required in order to support more complex ZWave deployments.</p>
<dt>This file is part of <strong>py-openzwave</strong> project <aclass="reference external" href="https://github.com/maartendamen/py-openzwave">https://github.com/maartendamen/py-openzwave</a>.</dt>
125
-
<dd><tableclass="first last docutils field-list" frame="void" rules="none">
<p><strong>py-openzwave</strong> is free software: you can redistribute it and/or modify
139
-
it under the terms of the GNU General Public License as published by
140
-
the Free Software Foundation, either version 3 of the License, or
141
-
(at your option) any later version.</p>
142
-
<p><strong>py-openzwave</strong> is distributed in the hope that it will be useful,
143
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
144
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
145
-
GNU General Public License for more details.
146
-
You should have received a copy of the GNU General Public License
147
-
along with py-openzwave. If not, see <aclass="reference external" href="http://www.gnu.org/licenses">http://www.gnu.org/licenses</a>.</p>
148
-
<p>A Python Singleton mixin class that makes use of some of the ideas
149
-
found at <aclass="reference external" href="http://c2.com/cgi/wiki?PythonSingleton">http://c2.com/cgi/wiki?PythonSingleton</a>. Just inherit
150
-
from it and you have a singleton. No code is required in
151
-
subclasses to create singleton behavior – inheritance from
152
-
Singleton is all that is needed.</p>
153
-
<p>Singleton creation is threadsafe.</p>
154
-
<p>USAGE:</p>
155
-
<p>Just inherit from Singleton. If you need a constructor, include
156
-
an __init__() method in your class as you usually would. However,
157
-
if your class is S, you instantiate the singleton using S.getInstance()
158
-
instead of S(). Repeated calls to S.getInstance() return the
159
-
originally-created instance.</p>
160
-
<p>For example:</p>
161
-
<p>class S(Singleton):</p>
162
-
<blockquote>
163
-
<div><dlclass="docutils">
164
-
<dt>def __init__(self, a, b=1):</dt>
165
-
<dd>pass</dd>
166
-
</dl>
167
-
</div></blockquote>
168
-
<p>S1 = S.getInstance(1, b=3)</p>
169
-
<p>Most of the time, that’s all you need to know. However, there are some
170
-
other useful behaviors. Read on for a full description:</p>
171
-
<olclass="arabic">
172
-
<li><pclass="first">Getting the singleton:</p>
173
-
<blockquote>
174
-
<div><p>S.getInstance()</p>
175
-
</div></blockquote>
176
-
</li>
177
-
</ol>
178
-
<p>returns the instance of S. If none exists, it is created.</p>
179
-
<olclass="arabic" start="2">
180
-
<li><pclass="first">The usual idiom to construct an instance by calling the class, i.e.</p>
181
-
<blockquote>
182
-
<div><p>S()</p>
183
-
</div></blockquote>
184
-
</li>
185
-
</ol>
186
-
<p>is disabled for the sake of clarity.</p>
187
-
<p>For one thing, the S() syntax means instantiation, but getInstance()
188
-
usually does not cause instantiation. So the S() syntax would
189
-
be misleading.</p>
190
-
<p>Because of that, if S() were allowed, a programmer who didn’t
191
-
happen to notice the inheritance from Singleton (or who
192
-
wasn’t fully aware of what a Singleton pattern
193
-
does) might think he was creating a new instance,
194
-
which could lead to very unexpected behavior.</p>
195
-
<p>So, overall, it is felt that it is better to make things clearer
196
-
by requiring the call of a class method that is defined in
197
-
Singleton. An attempt to instantiate via S() will result
198
-
in a SingletonException being raised.</p>
199
-
<p>3) Use __S.__init__() for instantiation processing,
200
-
since S.getInstance() runs S.__init__(), passing it the args it has received.</p>
201
-
<p>If no data needs to be passed in at instantiation time, you don’t need S.__init__().</p>
202
-
<p>4) If S.__init__(.) requires parameters, include them ONLY in the
203
-
first call to S.getInstance(). If subsequent calls have arguments,
204
-
a SingletonException is raised by default.</p>
205
-
<p>If you find it more convenient for subsequent calls to be allowed to
206
-
have arguments, but for those argumentsto be ignored, just include
207
-
‘ignoreSubsequent = True’ in your class definition, i.e.:</p>
208
-
<blockquote>
209
-
<div><p>class S(Singleton):</p>
210
-
<blockquote>
211
-
<div><p>ignoreSubsequent = True</p>
212
-
<dlclass="docutils">
213
-
<dt>def __init__(self, a, b=1):</dt>
214
-
<dd>pass</dd>
215
-
</dl>
216
-
</div></blockquote>
217
-
</div></blockquote>
218
-
<p>5) For testing, it is sometimes convenient for all existing singleton
219
-
instances to be forgotten, so that new instantiations can occur. For that
220
-
reason, a forgetAllSingletons() function is included. Just call</p>
221
-
<blockquote>
222
-
<div>forgetAllSingletons()</div></blockquote>
223
-
<p>and it is as if no earlier instantiations have occurred.</p>
224
-
<p>6) As an implementation detail, classes that inherit
225
-
from Singleton may not have their own __new__
226
-
methods. To make sure this requirement is followed,
227
-
an exception is raised if a Singleton subclass includ
228
-
es __new__. This happens at subclass instantiation
229
-
time (by means of the MetaSingleton metaclass.</p>
230
-
<p>By Gary Robinson, <aclass="reference external" href="mailto:grobinson%40flyfi.com">grobinson<span>@</span>flyfi<span>.</span>com</a>. No rights reserved –
231
-
placed in the public domain – which is only reasonable considering
232
-
how much it owes to other people’s code and ideas which are in the
233
-
public domain. The idea of using a metaclass came from
0 commit comments