moat-kv-ow 0.9.3__tar.gz → 0.9.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- moat_kv_ow-0.9.5/LICENSE.txt +14 -0
- {moat-kv-ow-0.9.3/moat_kv_ow.egg-info → moat_kv_ow-0.9.5}/PKG-INFO +6 -5
- {moat-kv-ow-0.9.3 → moat_kv_ow-0.9.5}/moat/kv/ow/__init__.py +2 -0
- moat_kv_ow-0.9.5/moat/kv/ow/_cfg.yaml +2 -0
- {moat-kv-ow-0.9.3 → moat_kv_ow-0.9.5}/moat/kv/ow/_main.py +17 -8
- {moat-kv-ow-0.9.3 → moat_kv_ow-0.9.5}/moat/kv/ow/mock.py +9 -3
- {moat-kv-ow-0.9.3 → moat_kv_ow-0.9.5}/moat/kv/ow/model.py +35 -14
- {moat-kv-ow-0.9.3 → moat_kv_ow-0.9.5}/moat/kv/ow/task.py +6 -2
- {moat-kv-ow-0.9.3 → moat_kv_ow-0.9.5/moat_kv_ow.egg-info}/PKG-INFO +6 -5
- {moat-kv-ow-0.9.3 → moat_kv_ow-0.9.5}/moat_kv_ow.egg-info/SOURCES.txt +3 -12
- moat_kv_ow-0.9.5/moat_kv_ow.egg-info/requires.txt +1 -0
- {moat-kv-ow-0.9.3 → moat_kv_ow-0.9.5}/pyproject.toml +6 -9
- moat-kv-ow-0.9.3/.gitignore +0 -8
- moat-kv-ow-0.9.3/.pylintrc +0 -3
- moat-kv-ow-0.9.3/Makefile +0 -14
- moat-kv-ow-0.9.3/TODO.rst +0 -5
- moat-kv-ow-0.9.3/USAGE.rst +0 -100
- moat-kv-ow-0.9.3/moat/kv/ow/_config.yaml +0 -4
- moat-kv-ow-0.9.3/moat-kv-ow@.service +0 -19
- moat-kv-ow-0.9.3/moat_kv_ow.egg-info/requires.txt +0 -1
- moat-kv-ow-0.9.3/tests/__init__.py +0 -0
- moat-kv-ow-0.9.3/tests/conftest.py +0 -5
- moat-kv-ow-0.9.3/tests/test_alarm.py +0 -75
- moat-kv-ow-0.9.3/tools/update-0-4.py +0 -20
- {moat-kv-ow-0.9.3 → moat_kv_ow-0.9.5}/README.rst +0 -0
- {moat-kv-ow-0.9.3 → moat_kv_ow-0.9.5}/moat_kv_ow.egg-info/dependency_links.txt +0 -0
- {moat-kv-ow-0.9.3 → moat_kv_ow-0.9.5}/moat_kv_ow.egg-info/top_level.txt +0 -0
- {moat-kv-ow-0.9.3 → moat_kv_ow-0.9.5}/setup.cfg +0 -0
@@ -0,0 +1,14 @@
|
|
1
|
+
The code in this repository, and all MoaT submodules it refers to,
|
2
|
+
is part of the MoaT project.
|
3
|
+
|
4
|
+
Unless a submodule's LICENSE.txt states otherwise, all included files are
|
5
|
+
licensed under the LGPL V3, as published by the FSF at
|
6
|
+
https://www.gnu.org/licenses/lgpl-3.0.html .
|
7
|
+
|
8
|
+
In addition to the LGPL's terms, the author(s) respectfully ask all users of
|
9
|
+
this code to contribute any bug fixes or enhancements. Also, please link back to
|
10
|
+
https://M-o-a-T.org.
|
11
|
+
|
12
|
+
Thank you.
|
13
|
+
|
14
|
+
Copyright © 2021 ff.: the MoaT contributor(s), as per the git changelog(s).
|
@@ -1,20 +1,21 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.4
|
2
2
|
Name: moat-kv-ow
|
3
|
-
Version: 0.9.
|
3
|
+
Version: 0.9.5
|
4
4
|
Summary: 1wire connector for MoaT-KV
|
5
5
|
Author-email: Matthias Urlichs <matthias@urlichs.de>
|
6
6
|
Project-URL: homepage, https://m-o-a-t.org
|
7
|
-
Project-URL: repository, https://github.com/M-o-a-T/moat
|
7
|
+
Project-URL: repository, https://github.com/M-o-a-T/moat
|
8
8
|
Keywords: MoaT
|
9
9
|
Classifier: Development Status :: 4 - Beta
|
10
10
|
Classifier: Intended Audience :: Information Technology
|
11
|
-
Classifier: License :: OSI Approved :: MIT License
|
12
|
-
Classifier: License :: OSI Approved :: Apache Software License
|
13
11
|
Classifier: Programming Language :: Python :: 3
|
14
12
|
Classifier: Topic :: Database
|
15
13
|
Classifier: Topic :: Home Automation
|
16
14
|
Requires-Python: >=3.8
|
17
15
|
Description-Content-Type: text/x-rst
|
16
|
+
License-File: LICENSE.txt
|
17
|
+
Requires-Dist: moat-kv~=0.70.23
|
18
|
+
Dynamic: license-file
|
18
19
|
|
19
20
|
==========
|
20
21
|
MoaT-KV-OW
|
@@ -1,7 +1,17 @@
|
|
1
1
|
# command line interface
|
2
|
+
from __future__ import annotations
|
2
3
|
|
3
4
|
import asyncclick as click
|
4
|
-
from moat.util import
|
5
|
+
from moat.util import (
|
6
|
+
yprint,
|
7
|
+
attrdict,
|
8
|
+
NotGiven,
|
9
|
+
P,
|
10
|
+
Path,
|
11
|
+
as_service,
|
12
|
+
attr_args,
|
13
|
+
ensure_cfg,
|
14
|
+
)
|
5
15
|
from moat.kv.data import data_get, node_attr
|
6
16
|
from .model import OWFSroot
|
7
17
|
|
@@ -17,6 +27,7 @@ async def cli(obj):
|
|
17
27
|
List Onewire devices, modify device handling …
|
18
28
|
"""
|
19
29
|
obj.data = await OWFSroot.as_handler(obj.client)
|
30
|
+
ensure_cfg("moat.kv.ow", obj.cfg)
|
20
31
|
|
21
32
|
|
22
33
|
@cli.command("list")
|
@@ -59,6 +70,7 @@ async def list_(obj, device, family):
|
|
59
70
|
return Path("%02x.%12x" % (p[0], p[1])) + p[2:]
|
60
71
|
|
61
72
|
if obj.meta:
|
73
|
+
|
62
74
|
def pm(p):
|
63
75
|
return Path(str(prefix + path)) + p
|
64
76
|
|
@@ -127,7 +139,7 @@ async def attr__(obj, device, family, write, attr, interval, path, attr_):
|
|
127
139
|
@attr_args
|
128
140
|
@click.argument("subpath", nargs=1, type=P, default=P(":"))
|
129
141
|
@click.pass_obj
|
130
|
-
async def set_(obj, device, family, subpath,
|
142
|
+
async def set_(obj, device, family, subpath, **kw):
|
131
143
|
"""Set or delete some random attribute.
|
132
144
|
|
133
145
|
For deletion, use '-e ATTR -'.
|
@@ -143,7 +155,7 @@ async def set_(obj, device, family, subpath, vars_, eval_, path_):
|
|
143
155
|
f, d = device.split(".", 2)[0:2]
|
144
156
|
fd = (int(f, 16), int(d, 16))
|
145
157
|
|
146
|
-
res = await node_attr(obj, obj.cfg.kv.ow.prefix + fd + subpath,
|
158
|
+
res = await node_attr(obj, obj.cfg.kv.ow.prefix + fd + subpath, **kw)
|
147
159
|
if res and obj.meta:
|
148
160
|
yprint(res, stream=obj.stdout)
|
149
161
|
|
@@ -164,9 +176,7 @@ async def server_(obj, name, host, port, delete):
|
|
164
176
|
if not name:
|
165
177
|
if host or port or delete:
|
166
178
|
raise click.UsageError("Use a server name to set parameters")
|
167
|
-
async for r in obj.client.get_tree(
|
168
|
-
prefix | "server", min_depth=1, max_depth=1
|
169
|
-
):
|
179
|
+
async for r in obj.client.get_tree(prefix | "server", min_depth=1, max_depth=1):
|
170
180
|
print(r.path[-1], file=obj.stdout)
|
171
181
|
return
|
172
182
|
elif len(name) > 1:
|
@@ -190,8 +200,7 @@ async def server_(obj, name, host, port, delete):
|
|
190
200
|
return
|
191
201
|
else:
|
192
202
|
value = None
|
193
|
-
res = await node_attr(
|
194
|
-
obj, prefix | "server" | name, ((P("server"), value),),(),())
|
203
|
+
res = await node_attr(obj, prefix | "server" | name, ((P("server"), value),), (), ())
|
195
204
|
if res and obj.meta:
|
196
205
|
yprint(res, stream=obj.stdout)
|
197
206
|
|
@@ -1,7 +1,9 @@
|
|
1
|
+
from __future__ import annotations
|
1
2
|
import os
|
2
3
|
import anyio
|
3
4
|
from functools import partial
|
4
5
|
from asyncowfs.mock import some_server
|
6
|
+
from moat.util import ensure_cfg
|
5
7
|
|
6
8
|
from .task import task
|
7
9
|
|
@@ -9,10 +11,11 @@ PORT = ((os.getpid() + 101) % 9999) + 40000
|
|
9
11
|
|
10
12
|
|
11
13
|
async def server(client, tree={}, options={}, evt=None): # pylint: disable=dangerous-default-value
|
12
|
-
|
13
14
|
async with anyio.create_task_group() as tg:
|
14
15
|
listener = await anyio.create_tcp_listener(
|
15
|
-
local_host="127.0.0.1",
|
16
|
+
local_host="127.0.0.1",
|
17
|
+
local_port=PORT,
|
18
|
+
reuse_port=True,
|
16
19
|
)
|
17
20
|
|
18
21
|
async def may_close():
|
@@ -24,8 +27,11 @@ async def server(client, tree={}, options={}, evt=None): # pylint: disable=dang
|
|
24
27
|
addr = listener.extra(anyio.abc.SocketAttribute.raw_socket).getsockname()
|
25
28
|
tg.start_soon(may_close)
|
26
29
|
|
30
|
+
cfg = {"kv": client._cfg}
|
31
|
+
ensure_cfg("moat.kv.ow", cfg)
|
32
|
+
|
27
33
|
await client.set(
|
28
|
-
client._cfg.
|
34
|
+
client._cfg.ow.prefix + ("server", "127.0.0.1"),
|
29
35
|
value=dict(server=dict(host="127.0.0.1", port=addr[1])),
|
30
36
|
)
|
31
37
|
|
@@ -1,6 +1,9 @@
|
|
1
1
|
"""
|
2
2
|
Moat-KV client data model for 1wire
|
3
3
|
"""
|
4
|
+
|
5
|
+
from __future__ import annotations
|
6
|
+
|
4
7
|
import anyio
|
5
8
|
|
6
9
|
from moat.util import combine_dict, attrdict
|
@@ -60,14 +63,16 @@ class OWFSattr(ClientEntry):
|
|
60
63
|
src_attr = val.get("src_attr", ())
|
61
64
|
if force or src != self.watch_src:
|
62
65
|
if self.watch_src_scope is not None:
|
63
|
-
|
66
|
+
self.watch_src_scope.cancel()
|
64
67
|
self.watch_src = src
|
65
68
|
self.watch_src_attr = src_attr
|
66
69
|
if src is not None:
|
67
70
|
await self.root._tg.start(self._watch_src)
|
68
71
|
else:
|
69
72
|
await self.root.err.record_working(
|
70
|
-
"owfs",
|
73
|
+
"owfs",
|
74
|
+
self.subpath + ("write",),
|
75
|
+
comment="dropped",
|
71
76
|
)
|
72
77
|
|
73
78
|
# poll OWFS
|
@@ -88,7 +93,9 @@ class OWFSattr(ClientEntry):
|
|
88
93
|
await dev.set_polling_interval(self.attr, intv)
|
89
94
|
else:
|
90
95
|
await self.root.err.record_working(
|
91
|
-
"owfs",
|
96
|
+
"owfs",
|
97
|
+
self.subpath + ("read",),
|
98
|
+
comment="dropped",
|
92
99
|
)
|
93
100
|
except RuntimeError as exc:
|
94
101
|
await self.root.err.record_error("owfs", self.subpath + ("read",), exc=exc)
|
@@ -133,13 +140,16 @@ class OWFSattr(ClientEntry):
|
|
133
140
|
Task that monitors one entry and writes its value to the 1wire
|
134
141
|
device.
|
135
142
|
"""
|
136
|
-
|
143
|
+
with anyio.CancelScope() as sc:
|
137
144
|
try:
|
138
145
|
async with self.client.watch(
|
139
|
-
self.watch_src,
|
146
|
+
self.watch_src,
|
147
|
+
min_depth=0,
|
148
|
+
max_depth=0,
|
149
|
+
fetch=True,
|
140
150
|
) as wp:
|
141
151
|
if self.watch_src_scope is not None:
|
142
|
-
|
152
|
+
self.watch_src_scope.cancel()
|
143
153
|
self.watch_src_scope = sc
|
144
154
|
task_status.started()
|
145
155
|
|
@@ -157,19 +167,27 @@ class OWFSattr(ClientEntry):
|
|
157
167
|
"owfs",
|
158
168
|
self.subpath + ("write",),
|
159
169
|
comment="Attribute missing",
|
160
|
-
data={
|
170
|
+
data={
|
171
|
+
"key": k,
|
172
|
+
"attr": self.watch_src_attr,
|
173
|
+
"msg": msg,
|
174
|
+
},
|
161
175
|
)
|
162
176
|
return
|
163
177
|
else:
|
164
178
|
dev = self.node.dev
|
165
179
|
if dev is None:
|
166
180
|
await self.root.err.record_error(
|
167
|
-
"owfs",
|
181
|
+
"owfs",
|
182
|
+
self.subpath + ("write",),
|
183
|
+
comment="device missing",
|
168
184
|
)
|
169
185
|
return
|
170
186
|
await dev.set(*self.attr, value=val)
|
171
187
|
await self.root.err.record_working(
|
172
|
-
"owfs",
|
188
|
+
"owfs",
|
189
|
+
self.subpath + ("write",),
|
190
|
+
comment="write OK",
|
173
191
|
)
|
174
192
|
|
175
193
|
except Exception as exc:
|
@@ -237,7 +255,7 @@ class OWFSfamily(ClientEntry):
|
|
237
255
|
def child_type(cls, name):
|
238
256
|
if not isinstance(name, int):
|
239
257
|
return ClientEntry
|
240
|
-
if name <= 0 or name > 16
|
258
|
+
if name <= 0 or name > 16**12:
|
241
259
|
return ClientEntry
|
242
260
|
return cls.cls
|
243
261
|
|
@@ -301,15 +319,18 @@ class OWFSroot(ClientRoot):
|
|
301
319
|
kls.cls[name] = FamilyX
|
302
320
|
return FamilyX
|
303
321
|
|
322
|
+
|
304
323
|
class BrokenDict:
|
305
324
|
def __getattr__(self, k, v=None):
|
306
|
-
import pdb
|
307
|
-
|
308
|
-
|
325
|
+
import pdb
|
326
|
+
|
327
|
+
pdb.set_trace()
|
328
|
+
return object.__getattribute__(self, k, v)
|
329
|
+
|
309
330
|
|
310
331
|
@OWFSroot.register(0x10)
|
311
332
|
class TempNode(OWFSnode):
|
312
|
-
CFG = BrokenDict()
|
333
|
+
CFG = BrokenDict() # {"temperature": 30}
|
313
334
|
|
314
335
|
@classmethod
|
315
336
|
def child_type(cls, name):
|
@@ -2,6 +2,8 @@
|
|
2
2
|
OWFS task for DistKV
|
3
3
|
"""
|
4
4
|
|
5
|
+
from __future__ import annotations
|
6
|
+
|
5
7
|
import anyio
|
6
8
|
from asyncowfs import OWFS
|
7
9
|
from asyncowfs.event import (
|
@@ -51,7 +53,9 @@ async def mon(ow, hd):
|
|
51
53
|
if isinstance(msg.attribute, str):
|
52
54
|
attr = (attr,)
|
53
55
|
await node.root.err.record_error(
|
54
|
-
"onewire",
|
56
|
+
"onewire",
|
57
|
+
Path.build(node.subpath) + attr,
|
58
|
+
exc=msg.exception,
|
55
59
|
)
|
56
60
|
|
57
61
|
elif isinstance(msg, DeviceValue):
|
@@ -70,7 +74,7 @@ async def task(client, cfg, server=None, evt=None):
|
|
70
74
|
async with OWFS() as ow:
|
71
75
|
hd = await OWFSroot.as_handler(client)
|
72
76
|
await ow.add_task(mon, ow, hd)
|
73
|
-
port = cfg.
|
77
|
+
port = cfg.ow.port
|
74
78
|
if not server:
|
75
79
|
si = ((s._name, s) for s in hd.server)
|
76
80
|
elif isinstance(server, str):
|
@@ -1,20 +1,21 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.4
|
2
2
|
Name: moat-kv-ow
|
3
|
-
Version: 0.9.
|
3
|
+
Version: 0.9.5
|
4
4
|
Summary: 1wire connector for MoaT-KV
|
5
5
|
Author-email: Matthias Urlichs <matthias@urlichs.de>
|
6
6
|
Project-URL: homepage, https://m-o-a-t.org
|
7
|
-
Project-URL: repository, https://github.com/M-o-a-T/moat
|
7
|
+
Project-URL: repository, https://github.com/M-o-a-T/moat
|
8
8
|
Keywords: MoaT
|
9
9
|
Classifier: Development Status :: 4 - Beta
|
10
10
|
Classifier: Intended Audience :: Information Technology
|
11
|
-
Classifier: License :: OSI Approved :: MIT License
|
12
|
-
Classifier: License :: OSI Approved :: Apache Software License
|
13
11
|
Classifier: Programming Language :: Python :: 3
|
14
12
|
Classifier: Topic :: Database
|
15
13
|
Classifier: Topic :: Home Automation
|
16
14
|
Requires-Python: >=3.8
|
17
15
|
Description-Content-Type: text/x-rst
|
16
|
+
License-File: LICENSE.txt
|
17
|
+
Requires-Dist: moat-kv~=0.70.23
|
18
|
+
Dynamic: license-file
|
18
19
|
|
19
20
|
==========
|
20
21
|
MoaT-KV-OW
|
@@ -1,14 +1,9 @@
|
|
1
|
-
.
|
2
|
-
.pylintrc
|
3
|
-
Makefile
|
1
|
+
LICENSE.txt
|
4
2
|
README.rst
|
5
|
-
TODO.rst
|
6
|
-
USAGE.rst
|
7
|
-
moat-kv-ow@.service
|
8
3
|
pyproject.toml
|
9
4
|
setup.cfg
|
10
5
|
moat/kv/ow/__init__.py
|
11
|
-
moat/kv/ow/
|
6
|
+
moat/kv/ow/_cfg.yaml
|
12
7
|
moat/kv/ow/_main.py
|
13
8
|
moat/kv/ow/mock.py
|
14
9
|
moat/kv/ow/model.py
|
@@ -17,8 +12,4 @@ moat_kv_ow.egg-info/PKG-INFO
|
|
17
12
|
moat_kv_ow.egg-info/SOURCES.txt
|
18
13
|
moat_kv_ow.egg-info/dependency_links.txt
|
19
14
|
moat_kv_ow.egg-info/requires.txt
|
20
|
-
moat_kv_ow.egg-info/top_level.txt
|
21
|
-
tests/__init__.py
|
22
|
-
tests/conftest.py
|
23
|
-
tests/test_alarm.py
|
24
|
-
tools/update-0-4.py
|
15
|
+
moat_kv_ow.egg-info/top_level.txt
|
@@ -0,0 +1 @@
|
|
1
|
+
moat-kv~=0.70.23
|
@@ -1,36 +1,33 @@
|
|
1
1
|
[build-system]
|
2
2
|
build-backend = "setuptools.build_meta"
|
3
|
-
requires = [ "setuptools", "wheel",
|
3
|
+
requires = [ "setuptools", "wheel",]
|
4
4
|
|
5
5
|
[project]
|
6
6
|
classifiers = [
|
7
7
|
"Development Status :: 4 - Beta",
|
8
8
|
"Intended Audience :: Information Technology",
|
9
|
-
"License :: OSI Approved :: MIT License",
|
10
|
-
"License :: OSI Approved :: Apache Software License",
|
11
9
|
"Programming Language :: Python :: 3",
|
12
10
|
"Topic :: Database",
|
13
11
|
"Topic :: Home Automation",
|
14
12
|
]
|
15
13
|
dependencies = [
|
16
|
-
"moat-kv ~= 0.70.
|
14
|
+
"moat-kv ~= 0.70.23",
|
17
15
|
]
|
18
|
-
|
16
|
+
version = "0.9.5"
|
19
17
|
keywords = [ "MoaT",]
|
20
18
|
requires-python = ">=3.8"
|
21
19
|
name = "moat-kv-ow"
|
22
20
|
description = "1wire connector for MoaT-KV"
|
23
21
|
readme = "README.rst"
|
22
|
+
license-files = ["LICENSE.txt"]
|
23
|
+
|
24
24
|
[[project.authors]]
|
25
25
|
email = "matthias@urlichs.de"
|
26
26
|
name = "Matthias Urlichs"
|
27
27
|
|
28
|
-
[project.license]
|
29
|
-
file = "LICENSE"
|
30
|
-
|
31
28
|
[project.urls]
|
32
29
|
homepage = "https://m-o-a-t.org"
|
33
|
-
repository = "https://github.com/M-o-a-T/moat
|
30
|
+
repository = "https://github.com/M-o-a-T/moat"
|
34
31
|
|
35
32
|
[tool.flake8]
|
36
33
|
max-line-length = 99
|
moat-kv-ow-0.9.3/.gitignore
DELETED
moat-kv-ow-0.9.3/.pylintrc
DELETED
moat-kv-ow-0.9.3/Makefile
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/make -f
|
2
|
-
|
3
|
-
PACKAGE = moat-kv-ow
|
4
|
-
MAKEINCL ?= $(shell python3 -mmoat src path)/make/py
|
5
|
-
|
6
|
-
ifneq ($(wildcard $(MAKEINCL)),)
|
7
|
-
include $(MAKEINCL)
|
8
|
-
# availabe via https://github.com/moat-src
|
9
|
-
|
10
|
-
else
|
11
|
-
%:
|
12
|
-
@echo "Please fix 'python3 -mmoat src path'."
|
13
|
-
@exit 1
|
14
|
-
endif
|
moat-kv-ow-0.9.3/TODO.rst
DELETED
moat-kv-ow-0.9.3/USAGE.rst
DELETED
@@ -1,100 +0,0 @@
|
|
1
|
-
==============
|
2
|
-
Using DistOWFS
|
3
|
-
==============
|
4
|
-
|
5
|
-
Run "moat kw ow monitor" to connect to the server on localhost.
|
6
|
-
|
7
|
-
See "moat dump cfg owfs" for configuration options. Specifically, use
|
8
|
-
this config snippet to connect to two external servers instead of localhost::
|
9
|
-
|
10
|
-
owfs:
|
11
|
-
server:
|
12
|
-
- host: one.example
|
13
|
-
- host: two.example
|
14
|
-
|
15
|
-
|
16
|
-
Command line
|
17
|
-
============
|
18
|
-
|
19
|
-
|
20
|
-
.. program:: moat kw ow
|
21
|
-
|
22
|
-
The main entry point for this extension.
|
23
|
-
|
24
|
-
|
25
|
-
.. program:: moat kw ow list
|
26
|
-
|
27
|
-
Print the current state of your 1wire devices.
|
28
|
-
|
29
|
-
This command does not access the device or show on which bus it is; this is
|
30
|
-
solely for displaying the configuration of its interaction with DistKV.
|
31
|
-
|
32
|
-
.. option:: family
|
33
|
-
|
34
|
-
You can limit the display to a family code.
|
35
|
-
|
36
|
-
.. option:: device
|
37
|
-
|
38
|
-
If you add the device ID, only that devices data is displayed.
|
39
|
-
|
40
|
-
Use '-' to show the data stored at the family entry.
|
41
|
-
|
42
|
-
|
43
|
-
.. program:: moat kw ow monitor
|
44
|
-
|
45
|
-
This is a stand-alone 1wire monitor. It connects to all configured servers
|
46
|
-
and runs polls and monitors.
|
47
|
-
|
48
|
-
No options yet.
|
49
|
-
|
50
|
-
|
51
|
-
.. program:: moat kw ow poll
|
52
|
-
|
53
|
-
Configure polling.
|
54
|
-
|
55
|
-
If the device (and the given attribute) supports simultaneous conversion,
|
56
|
-
this might cause results to be read more often than configured here.
|
57
|
-
|
58
|
-
.. option:: -f, --family <code>
|
59
|
-
|
60
|
-
Change the poll interval's default for this family code.
|
61
|
-
|
62
|
-
.. option:: -d, --device <family.device>
|
63
|
-
|
64
|
-
Change the poll interval for this device.
|
65
|
-
|
66
|
-
.. option:: <attribute>
|
67
|
-
|
68
|
-
Set the interval on this attribute. Use a ``/`` separator for sub-attributes.
|
69
|
-
|
70
|
-
.. option:: <interval>
|
71
|
-
|
72
|
-
The interval to poll at. Use ``-`` to disable polling.
|
73
|
-
|
74
|
-
|
75
|
-
.. program:: moat kw ow set
|
76
|
-
|
77
|
-
You can use this command to add arbitrary values to a device's entry. Use
|
78
|
-
this e.g. to add a note where the device is located, or to signal your own
|
79
|
-
code.
|
80
|
-
|
81
|
-
.. option:: -f, --family <code>
|
82
|
-
|
83
|
-
Change an attribute on this family code.
|
84
|
-
|
85
|
-
.. option:: -d, --device <family.device>
|
86
|
-
|
87
|
-
Change an attribute on this device.
|
88
|
-
|
89
|
-
.. option:: -v, --value
|
90
|
-
|
91
|
-
The value to set.
|
92
|
-
|
93
|
-
.. option:: -e, --eval
|
94
|
-
|
95
|
-
Flag that the value is a Python expression and should be evaluated.
|
96
|
-
|
97
|
-
.. option:: <name>…
|
98
|
-
|
99
|
-
The attribute name to set. Use more than once for accessing sub-dicts.
|
100
|
-
|
@@ -1,19 +0,0 @@
|
|
1
|
-
[Unit]
|
2
|
-
Description=Moat-KV OWFS server
|
3
|
-
After=moat-kv.service
|
4
|
-
Requires=moat-kv.service
|
5
|
-
|
6
|
-
ConditionFileNotEmpty=/etc/moat/moat.cfg
|
7
|
-
|
8
|
-
[Install]
|
9
|
-
WantedBy=multi-user.target
|
10
|
-
|
11
|
-
[Service]
|
12
|
-
Type=notify
|
13
|
-
ExecStart=/usr/bin/moat kv ow monitor %I
|
14
|
-
|
15
|
-
TimeoutSec=300
|
16
|
-
WatchdogSec=10
|
17
|
-
|
18
|
-
Restart=always
|
19
|
-
RestartSec=30
|
@@ -1 +0,0 @@
|
|
1
|
-
moat-kv~=0.70.2
|
File without changes
|
@@ -1,75 +0,0 @@
|
|
1
|
-
"""
|
2
|
-
Test program cloned from asyncowfs, but using MoaT-KV for end-to-semi-end testing.
|
3
|
-
"""
|
4
|
-
import sys
|
5
|
-
import anyio
|
6
|
-
from copy import deepcopy
|
7
|
-
from functools import partial
|
8
|
-
|
9
|
-
from asyncowfs.mock import structs
|
10
|
-
from moat.kv.mock.mqtt import stdtest
|
11
|
-
|
12
|
-
from moat.util import attrdict, Path, P, load_ext
|
13
|
-
from moat.kv.data import data_get
|
14
|
-
|
15
|
-
owfs_mock = load_ext("moat.kv.ow.mock")
|
16
|
-
|
17
|
-
import logging
|
18
|
-
|
19
|
-
logger = logging.getLogger(__name__)
|
20
|
-
|
21
|
-
# We can just use 'async def test_*' to define async tests.
|
22
|
-
# This also uses a virtual clock fixture, so time passes quickly and
|
23
|
-
# predictably.
|
24
|
-
|
25
|
-
basic_tree = {
|
26
|
-
"bus.0": {
|
27
|
-
"alarm": {},
|
28
|
-
"simultaneous": {"temperature": 0},
|
29
|
-
"10.345678.90": {
|
30
|
-
"latesttemp": "12.5",
|
31
|
-
"temperature": "12.5",
|
32
|
-
"templow": "15",
|
33
|
-
"temphigh": "20",
|
34
|
-
"foo": {"bar": 123, "plugh.A": 1, "plugh.B": 2, "plugh.C": 3},
|
35
|
-
},
|
36
|
-
},
|
37
|
-
"structure": structs,
|
38
|
-
}
|
39
|
-
|
40
|
-
|
41
|
-
async def test_alarm(mock_clock):
|
42
|
-
mock_clock.autojump_threshold = 0.1
|
43
|
-
my_tree = deepcopy(basic_tree)
|
44
|
-
dt = my_tree["bus.0"]["10.345678.90"]
|
45
|
-
async with stdtest(test_0={"init": 125}, n=1, tocks=200) as st, st.client(0) as client:
|
46
|
-
evt = anyio.Event()
|
47
|
-
obj = attrdict(client=client, meta=0, stdout=sys.stdout)
|
48
|
-
st.tg.start_soon(partial(owfs_mock.server, client, tree=my_tree, evt=evt))
|
49
|
-
await evt.wait()
|
50
|
-
assert dt["foo"]["bar"] == 123
|
51
|
-
await st.run("owfs attr -d 10.345678.90 -i 5 temperature test.foo.temp")
|
52
|
-
await st.run("owfs attr -d 10.345678.90 -w templow test.foo.low")
|
53
|
-
await st.run("owfs attr -d 10.345678.90 -w foo.bar -a bar:1 test.foo.what.ever")
|
54
|
-
await st.run("owfs attr -d 10.345678.90 -i 4 -a baz:2 foo.plugh:1 test.foo.this")
|
55
|
-
res = await client.set(P("test.foo.this"), value={"this": "is", "baz": {3: 33}})
|
56
|
-
await anyio.sleep(10)
|
57
|
-
await data_get(obj, Path())
|
58
|
-
|
59
|
-
await client.set(P("test.foo.low"), 11)
|
60
|
-
await client.set(P("test.foo.what.ever"), {"Hello": "No", "bar": {0: 99, 1: 13}})
|
61
|
-
await anyio.sleep(1)
|
62
|
-
res = await client.get(P("test.foo.temp"))
|
63
|
-
assert res.value == 12.5
|
64
|
-
dt["latesttemp"] = 42
|
65
|
-
dt["temperature"] = 42
|
66
|
-
dt["foo"]["plugh.B"] = 22
|
67
|
-
await anyio.sleep(6)
|
68
|
-
res = await client.get(P("test.foo.temp"))
|
69
|
-
await data_get(obj, Path())
|
70
|
-
assert res.value == 42
|
71
|
-
assert dt["foo"]["bar"] == "13"
|
72
|
-
res = await client.get(P("test.foo.this"))
|
73
|
-
assert res.value == {"this": "is", "baz": {2: 22, 3: 33}}
|
74
|
-
|
75
|
-
await st.tg.cancel_scope.cancel()
|
@@ -1,20 +0,0 @@
|
|
1
|
-
#!/usr/bin/python3
|
2
|
-
|
3
|
-
import anyio
|
4
|
-
from moat.util import P
|
5
|
-
from moat.kv.client import open_client
|
6
|
-
|
7
|
-
async def mod_owfs():
|
8
|
-
async with open_client() as c:
|
9
|
-
async for r in c.get_tree(P(":.distkv.onewire"),min_depth=2,max_depth=2,nchain=2):
|
10
|
-
try:
|
11
|
-
at = r.value.pop("attr")
|
12
|
-
except KeyError:
|
13
|
-
continue
|
14
|
-
await c.set(P(":.distkv.onewire")+r.path,value=r.value,chain=r.chain)
|
15
|
-
# for k,v in at.items():
|
16
|
-
# print(r.path+P(k.replace('/',':')),v)
|
17
|
-
# await c.set(P(":.distkv.onewire")+r.path+P(k.replace('/',':')),value=v)
|
18
|
-
|
19
|
-
anyio.run(mod_owfs)
|
20
|
-
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|