signalk-cli 1.0.0__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.
- signalk_cli-1.0.0/PKG-INFO +281 -0
- signalk_cli-1.0.0/README.md +256 -0
- signalk_cli-1.0.0/pyproject.toml +97 -0
- signalk_cli-1.0.0/src/signalk_cli/__init__.py +1 -0
- signalk_cli-1.0.0/src/signalk_cli/__main__.py +7 -0
- signalk_cli-1.0.0/src/signalk_cli/history/__init__.py +31 -0
- signalk_cli-1.0.0/src/signalk_cli/history/__main__.py +3 -0
- signalk_cli-1.0.0/src/signalk_cli/history/cli.py +499 -0
- signalk_cli-1.0.0/src/signalk_cli/history/history_api.py +231 -0
- signalk_cli-1.0.0/src/signalk_cli/history/output.py +190 -0
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: signalk-cli
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Query the SignalK v2 History API and export data as CSV or Apache Arrow Feather
|
|
5
|
+
Keywords: signalk,sailing,marine,nmea,boating
|
|
6
|
+
Author: jey burrows
|
|
7
|
+
Author-email: jey burrows <jrb@rhizomatics.org.uk>
|
|
8
|
+
License-Expression: Apache-2.0
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Environment :: Console
|
|
11
|
+
Classifier: Natural Language :: English
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Topic :: Scientific/Engineering
|
|
14
|
+
Classifier: Programming Language :: Python
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
17
|
+
Requires-Dist: click>=8.3.3
|
|
18
|
+
Requires-Dist: niquests>=2.28
|
|
19
|
+
Requires-Dist: pyarrow>=17.0
|
|
20
|
+
Requires-Dist: zeroconf>=0.149.16,<0.150.0
|
|
21
|
+
Requires-Python: >=3.13
|
|
22
|
+
Project-URL: Homepage, https://github.com/rhizomatics/signalk-cli
|
|
23
|
+
Project-URL: Repository, https://github.com/rhizomatics/signalk-cli
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
|
|
26
|
+
# SignalK CLI
|
|
27
|
+
|
|
28
|
+
Query and explore SignalK APIs from the command line, and export data as CSV or Apache Arrow Feather.
|
|
29
|
+
|
|
30
|
+
Presently the [SignalK v2 History API](https://signalk.org/https://demo.signalk.org/documentation/Developing/REST_APIs/History_API.html) is supported.
|
|
31
|
+
|
|
32
|
+
## Installation
|
|
33
|
+
|
|
34
|
+
### PyPi
|
|
35
|
+
|
|
36
|
+
```pip install signalk-cli``` or ```uv pip install signalk-cli```
|
|
37
|
+
|
|
38
|
+
### Local Copy
|
|
39
|
+
|
|
40
|
+
Requires Python 3.13+ and [uv](https://docs.astral.sh/uv/).
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
git clone https://github.com/rhizomatics/signalk-cli
|
|
44
|
+
cd signalk-cli
|
|
45
|
+
uv sync
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Running
|
|
49
|
+
|
|
50
|
+
Run via `python -m signalk_cli.history <command>`.
|
|
51
|
+
|
|
52
|
+
## Determining SignalK host name
|
|
53
|
+
|
|
54
|
+
If not host name set as an argument, the CLI will look for a `SIGNALK_HOST` environment variable, and failing that attempt to automatically discover
|
|
55
|
+
the host using mDNS (aka Bonjour).
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
export SIGNALK_HOST=192.168.6.99 # http:// is added automatically if omitted
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Help
|
|
62
|
+
|
|
63
|
+
Run with no arguments to list available commands:
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
$ python -m signalk_cli.history
|
|
67
|
+
Usage: signak_cli.history [OPTIONS] COMMAND [ARGS]...
|
|
68
|
+
|
|
69
|
+
SignalK v2 history CLI.
|
|
70
|
+
|
|
71
|
+
Commands:
|
|
72
|
+
list-contexts List contexts that have historical data for the given time range.
|
|
73
|
+
list-paths List paths that have data for the given time range.
|
|
74
|
+
list-providers List registered history providers.
|
|
75
|
+
query Query history and write results as CSV or Feather.
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Commands
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
### `query`
|
|
82
|
+
|
|
83
|
+
Fetch historical values for one or more paths and write to a file (default) or stdout. Aggregation can be controlled in the same way as the History API itself
|
|
84
|
+
or a default form where `min_value`,`avg_value` and `max_value` are returned for every period.
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
python -m signalk_cli.history query [OPTIONS] PATH...
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
**PATH** arguments may be:
|
|
91
|
+
- **Literal paths** — e.g. `navigation.speedOverGround`
|
|
92
|
+
- **Regex / glob patterns** — any argument containing metacharacters (`*`, `.`, `[`, `(`, etc.) is matched against the server's `/paths` endpoint. Bare `*` is treated as a glob wildcard.
|
|
93
|
+
- **Inline path specs** — `path:method` or `path:method:param`, e.g. `navigation.speedOverGround:sma:5`. These pass through to the server unchanged.
|
|
94
|
+
|
|
95
|
+
#### Options
|
|
96
|
+
|
|
97
|
+
| Option | Default | Description |
|
|
98
|
+
|---|---|---|
|
|
99
|
+
| `--host` | `$SIGNALK_HOST` | Server base URL. `http://` added if scheme omitted. |
|
|
100
|
+
| `--from DATETIME` | — | Start of range (ISO 8601, e.g. `2026-05-26T00:00:00Z`) |
|
|
101
|
+
| `--to DATETIME` | now | End of range (ISO 8601) |
|
|
102
|
+
| `--duration DURATION` | — | Duration as seconds (`3600`) or ISO 8601 (`PT1H`, `PT15M`). Combined with `--from` or `--to`, or alone for a window ending now. |
|
|
103
|
+
| `--resolution RESOLUTION` | server default | Sample window size: seconds or time expression (`1s`, `1m`, `1h`, `1d`). |
|
|
104
|
+
| `-c, --context TEXT` | `vessels.self` | SignalK context |
|
|
105
|
+
| `--provider TEXT` | fetched & cached | History provider plugin id |
|
|
106
|
+
| `--no-cache` | — | Ignore the cached default provider |
|
|
107
|
+
| `--aggregation / --agg` | — | Aggregation method: `average`, `min`, `max`, `first`, `last`, `mid`, `middle_index`, `sma`, `ema`. Omit for wide mode (see below). |
|
|
108
|
+
| `--samples N` | server default | Sample count for `--agg sma` |
|
|
109
|
+
| `--alpha FLOAT` | server default | Alpha (0–1) for `--agg ema` |
|
|
110
|
+
| `--format [csv\|feather]` | from extension, else csv | Output format. Auto-detected from `.feather`, `.arrow`, `.fea` extensions. |
|
|
111
|
+
| `--no-header` | — | Suppress the CSV header row |
|
|
112
|
+
| `-o / --output FILE` | auto-named | Output file. Use `-` to write CSV to stdout. |
|
|
113
|
+
| `--stdout` | — | Print CSV to stdout. If `--output` is also given, writes to both. Not supported with feather. |
|
|
114
|
+
| `--bare` | — | Print CSV to stdout with **no informational messages** (server, provider, progress, row count). Ideal for piping to other tools. Implies `--stdout`. Not supported with feather. |
|
|
115
|
+
|
|
116
|
+
Output files are auto-named `signalk-history-<server>-<timestamp>.<ext>` in the current directory.
|
|
117
|
+
|
|
118
|
+
If no time range is given, the tool defaults to the hour ending now.
|
|
119
|
+
|
|
120
|
+
#### Output columns
|
|
121
|
+
|
|
122
|
+
**Wide mode** (default — no `--aggregation` and no inline specs): fetches `min`, `average`, and `max` for each path and writes them as separate columns:
|
|
123
|
+
|
|
124
|
+
```
|
|
125
|
+
timestamp, path, min_value, avg_value, max_value
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
**Narrow mode** (explicit `--aggregation` or inline path specs): single value column:
|
|
129
|
+
|
|
130
|
+
```
|
|
131
|
+
timestamp, path, value
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Structured values (positions, arrays) are JSON-encoded in the value column.
|
|
135
|
+
|
|
136
|
+
Feather output produces the same columns as Apache Arrow Feather, readable with pandas, Polars, R, pyarrow, etc.
|
|
137
|
+
|
|
138
|
+
#### Examples
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
# Last hour of speed — wide mode (min/max/avg columns), auto-named CSV
|
|
142
|
+
python -m signalk_cli.history query --host 10.36.10.21 --duration PT1H \
|
|
143
|
+
navigation.speedOverGround
|
|
144
|
+
|
|
145
|
+
# Wide mode printed to stdout
|
|
146
|
+
python -m signalk_cli.history query --host 10.36.10.21 --duration PT1H --stdout \
|
|
147
|
+
navigation.speedOverGround
|
|
148
|
+
|
|
149
|
+
# Simple moving average (5 samples), narrowed to one value column
|
|
150
|
+
python -m signalk_cli.history query --host 10.36.10.21 --duration PT1H \
|
|
151
|
+
--agg sma --samples 5 \
|
|
152
|
+
navigation.speedOverGround
|
|
153
|
+
|
|
154
|
+
# EMA with alpha 0.2
|
|
155
|
+
python -m signalk_cli.history query --host 10.36.10.21 --duration PT1H \
|
|
156
|
+
--agg ema --alpha 0.2 \
|
|
157
|
+
navigation.speedOverGround
|
|
158
|
+
|
|
159
|
+
# Inline spec — path:method, multiple paths with different methods
|
|
160
|
+
python -m signalk_cli.history query --host 10.36.10.21 --duration PT1H --stdout \
|
|
161
|
+
'navigation.speedOverGround:max' 'navigation.courseOverGroundTrue:average'
|
|
162
|
+
|
|
163
|
+
# Multiple literal paths, 1-minute resolution
|
|
164
|
+
python -m signalk_cli.history query --host 10.36.10.21 --duration PT1H --resolution 1m \
|
|
165
|
+
navigation.speedOverGround navigation.courseOverGroundTrue
|
|
166
|
+
|
|
167
|
+
# All navigation paths, specific date range, write to named file
|
|
168
|
+
python -m signalk_cli.history query --host 10.36.10.21 \
|
|
169
|
+
--from 2026-05-26T00:00:00Z --to 2026-05-27T00:00:00Z \
|
|
170
|
+
--output may26.csv \
|
|
171
|
+
'navigation\..*'
|
|
172
|
+
|
|
173
|
+
# Glob wildcard — all paths for the last 30 minutes as Feather
|
|
174
|
+
python -m signalk_cli.history query --host 10.36.10.21 --duration PT30M --format feather '*'
|
|
175
|
+
|
|
176
|
+
# Extension auto-selects feather format
|
|
177
|
+
python -m signalk_cli.history query --host 10.36.10.21 --duration PT1H \
|
|
178
|
+
-o out.feather navigation.speedOverGround
|
|
179
|
+
|
|
180
|
+
# Write to both a file and stdout
|
|
181
|
+
python -m signalk_cli.historyquery --host 10.36.10.21 --duration PT1H \
|
|
182
|
+
--output out.csv --stdout navigation.speedOverGround
|
|
183
|
+
|
|
184
|
+
# Duration in seconds, suppress header, pipe to another tool
|
|
185
|
+
python -m signalk_cli.history query --host 10.36.10.21 --duration 3600 --no-header --stdout \
|
|
186
|
+
navigation.speedOverGround | cut -d, -f1,3
|
|
187
|
+
|
|
188
|
+
# --bare: pure CSV output, no informational noise — pipe-friendly
|
|
189
|
+
python -m signalk_cli.history query --host 10.36.10.21 --duration PT1H --bare \
|
|
190
|
+
navigation.speedOverGround | awk -F, 'NR>1 {print $2, $3}'
|
|
191
|
+
|
|
192
|
+
# Different context
|
|
193
|
+
python -m signalk_cli.history query --host 10.36.10.21 --duration PT1H -c vessels.urn:mrn:imo:mmsi:123456789 \
|
|
194
|
+
navigation.speedOverGround
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
### `list-paths`
|
|
200
|
+
|
|
201
|
+
List all SignalK paths that have recorded data in a given time range.
|
|
202
|
+
|
|
203
|
+
```
|
|
204
|
+
python -m signalk_cli.history list-paths [OPTIONS]
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
Outputs one path per line to stdout. Defaults to the last hour if no time range is given. Accepts the same `--from`/`--to`/`--duration`, `--provider`/`--no-cache`, `-c/--context`, and `--bare` options as `query`.
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
# Paths recorded in the last hour
|
|
211
|
+
python -m signalk_cli.history list-paths --host 10.36.10.21
|
|
212
|
+
|
|
213
|
+
# Paths available on a specific day
|
|
214
|
+
python -m signalk_cli.historylist-paths --host 10.36.10.21 \
|
|
215
|
+
--from 2026-05-26T00:00:00Z --to 2026-05-27T00:00:00Z
|
|
216
|
+
|
|
217
|
+
# Pipe into grep
|
|
218
|
+
python -m signalk_cli.history list-paths --host 10.36.10.21 --duration PT24H | grep navigation
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
### `list-providers`
|
|
224
|
+
|
|
225
|
+
List all registered history provider plugins and identify the default. Supports `--bare` to suppress the "Server:" and provider-count lines.
|
|
226
|
+
|
|
227
|
+
```
|
|
228
|
+
python -m signalk_cli.history list-providers --host 10.36.10.21
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
Example output:
|
|
232
|
+
|
|
233
|
+
```
|
|
234
|
+
kip (default)
|
|
235
|
+
signalk-parquet
|
|
236
|
+
2 provider(s)
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
The default provider is used automatically when `--provider` is not specified on other commands. It is fetched once and cached in `~/.cache/signalk-cli/`.
|
|
240
|
+
|
|
241
|
+
---
|
|
242
|
+
|
|
243
|
+
### `list-contexts`
|
|
244
|
+
|
|
245
|
+
List SignalK contexts (vessels, aircraft, etc.) that have recorded data in a given time range.
|
|
246
|
+
|
|
247
|
+
```bash
|
|
248
|
+
python -m signalk_cli.history list-contexts [OPTIONS]
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
Defaults to the last hour if no time range is given.
|
|
252
|
+
|
|
253
|
+
```bash
|
|
254
|
+
python -m signalk_cli.history list-contexts --host 10.36.10.21
|
|
255
|
+
|
|
256
|
+
python -m signalk_cli.history list-contexts --host 10.36.10.21 \
|
|
257
|
+
--from 2026-05-26T00:00:00Z --to 2026-05-27T00:00:00Z
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
---
|
|
261
|
+
|
|
262
|
+
## Time range
|
|
263
|
+
|
|
264
|
+
All commands that query data accept the same three time parameters. At least one of `--from` or `--duration` must be provided (or the tool supplies a one-hour default).
|
|
265
|
+
|
|
266
|
+
| Parameter | Format | Examples |
|
|
267
|
+
|---|---|---|
|
|
268
|
+
| `--from` | ISO 8601 timestamp | `2026-05-26T00:00:00Z` |
|
|
269
|
+
| `--to` | ISO 8601 timestamp | `2026-05-27T00:00:00Z` |
|
|
270
|
+
| `--duration` | ISO 8601 duration or integer seconds | `PT1H`, `PT15M`, `3600` |
|
|
271
|
+
|
|
272
|
+
Typical combinations:
|
|
273
|
+
|
|
274
|
+
- `--duration PT1H` — last hour ending now
|
|
275
|
+
- `--from T --duration PT1H` — hour starting at T
|
|
276
|
+
- `--from T1 --to T2` — explicit range
|
|
277
|
+
- `--duration PT1H --to T` — hour ending at T
|
|
278
|
+
|
|
279
|
+
## Provider caching
|
|
280
|
+
|
|
281
|
+
The default history provider is fetched from the server once and cached per host in `~/.cache/signalk-history-cli/`. Pass `--no-cache` to force a fresh lookup, or `--provider <id>` to target a specific provider explicitly.
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
# SignalK CLI
|
|
2
|
+
|
|
3
|
+
Query and explore SignalK APIs from the command line, and export data as CSV or Apache Arrow Feather.
|
|
4
|
+
|
|
5
|
+
Presently the [SignalK v2 History API](https://signalk.org/https://demo.signalk.org/documentation/Developing/REST_APIs/History_API.html) is supported.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
### PyPi
|
|
10
|
+
|
|
11
|
+
```pip install signalk-cli``` or ```uv pip install signalk-cli```
|
|
12
|
+
|
|
13
|
+
### Local Copy
|
|
14
|
+
|
|
15
|
+
Requires Python 3.13+ and [uv](https://docs.astral.sh/uv/).
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
git clone https://github.com/rhizomatics/signalk-cli
|
|
19
|
+
cd signalk-cli
|
|
20
|
+
uv sync
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Running
|
|
24
|
+
|
|
25
|
+
Run via `python -m signalk_cli.history <command>`.
|
|
26
|
+
|
|
27
|
+
## Determining SignalK host name
|
|
28
|
+
|
|
29
|
+
If not host name set as an argument, the CLI will look for a `SIGNALK_HOST` environment variable, and failing that attempt to automatically discover
|
|
30
|
+
the host using mDNS (aka Bonjour).
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
export SIGNALK_HOST=192.168.6.99 # http:// is added automatically if omitted
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Help
|
|
37
|
+
|
|
38
|
+
Run with no arguments to list available commands:
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
$ python -m signalk_cli.history
|
|
42
|
+
Usage: signak_cli.history [OPTIONS] COMMAND [ARGS]...
|
|
43
|
+
|
|
44
|
+
SignalK v2 history CLI.
|
|
45
|
+
|
|
46
|
+
Commands:
|
|
47
|
+
list-contexts List contexts that have historical data for the given time range.
|
|
48
|
+
list-paths List paths that have data for the given time range.
|
|
49
|
+
list-providers List registered history providers.
|
|
50
|
+
query Query history and write results as CSV or Feather.
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Commands
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
### `query`
|
|
57
|
+
|
|
58
|
+
Fetch historical values for one or more paths and write to a file (default) or stdout. Aggregation can be controlled in the same way as the History API itself
|
|
59
|
+
or a default form where `min_value`,`avg_value` and `max_value` are returned for every period.
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
python -m signalk_cli.history query [OPTIONS] PATH...
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
**PATH** arguments may be:
|
|
66
|
+
- **Literal paths** — e.g. `navigation.speedOverGround`
|
|
67
|
+
- **Regex / glob patterns** — any argument containing metacharacters (`*`, `.`, `[`, `(`, etc.) is matched against the server's `/paths` endpoint. Bare `*` is treated as a glob wildcard.
|
|
68
|
+
- **Inline path specs** — `path:method` or `path:method:param`, e.g. `navigation.speedOverGround:sma:5`. These pass through to the server unchanged.
|
|
69
|
+
|
|
70
|
+
#### Options
|
|
71
|
+
|
|
72
|
+
| Option | Default | Description |
|
|
73
|
+
|---|---|---|
|
|
74
|
+
| `--host` | `$SIGNALK_HOST` | Server base URL. `http://` added if scheme omitted. |
|
|
75
|
+
| `--from DATETIME` | — | Start of range (ISO 8601, e.g. `2026-05-26T00:00:00Z`) |
|
|
76
|
+
| `--to DATETIME` | now | End of range (ISO 8601) |
|
|
77
|
+
| `--duration DURATION` | — | Duration as seconds (`3600`) or ISO 8601 (`PT1H`, `PT15M`). Combined with `--from` or `--to`, or alone for a window ending now. |
|
|
78
|
+
| `--resolution RESOLUTION` | server default | Sample window size: seconds or time expression (`1s`, `1m`, `1h`, `1d`). |
|
|
79
|
+
| `-c, --context TEXT` | `vessels.self` | SignalK context |
|
|
80
|
+
| `--provider TEXT` | fetched & cached | History provider plugin id |
|
|
81
|
+
| `--no-cache` | — | Ignore the cached default provider |
|
|
82
|
+
| `--aggregation / --agg` | — | Aggregation method: `average`, `min`, `max`, `first`, `last`, `mid`, `middle_index`, `sma`, `ema`. Omit for wide mode (see below). |
|
|
83
|
+
| `--samples N` | server default | Sample count for `--agg sma` |
|
|
84
|
+
| `--alpha FLOAT` | server default | Alpha (0–1) for `--agg ema` |
|
|
85
|
+
| `--format [csv\|feather]` | from extension, else csv | Output format. Auto-detected from `.feather`, `.arrow`, `.fea` extensions. |
|
|
86
|
+
| `--no-header` | — | Suppress the CSV header row |
|
|
87
|
+
| `-o / --output FILE` | auto-named | Output file. Use `-` to write CSV to stdout. |
|
|
88
|
+
| `--stdout` | — | Print CSV to stdout. If `--output` is also given, writes to both. Not supported with feather. |
|
|
89
|
+
| `--bare` | — | Print CSV to stdout with **no informational messages** (server, provider, progress, row count). Ideal for piping to other tools. Implies `--stdout`. Not supported with feather. |
|
|
90
|
+
|
|
91
|
+
Output files are auto-named `signalk-history-<server>-<timestamp>.<ext>` in the current directory.
|
|
92
|
+
|
|
93
|
+
If no time range is given, the tool defaults to the hour ending now.
|
|
94
|
+
|
|
95
|
+
#### Output columns
|
|
96
|
+
|
|
97
|
+
**Wide mode** (default — no `--aggregation` and no inline specs): fetches `min`, `average`, and `max` for each path and writes them as separate columns:
|
|
98
|
+
|
|
99
|
+
```
|
|
100
|
+
timestamp, path, min_value, avg_value, max_value
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
**Narrow mode** (explicit `--aggregation` or inline path specs): single value column:
|
|
104
|
+
|
|
105
|
+
```
|
|
106
|
+
timestamp, path, value
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Structured values (positions, arrays) are JSON-encoded in the value column.
|
|
110
|
+
|
|
111
|
+
Feather output produces the same columns as Apache Arrow Feather, readable with pandas, Polars, R, pyarrow, etc.
|
|
112
|
+
|
|
113
|
+
#### Examples
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
# Last hour of speed — wide mode (min/max/avg columns), auto-named CSV
|
|
117
|
+
python -m signalk_cli.history query --host 10.36.10.21 --duration PT1H \
|
|
118
|
+
navigation.speedOverGround
|
|
119
|
+
|
|
120
|
+
# Wide mode printed to stdout
|
|
121
|
+
python -m signalk_cli.history query --host 10.36.10.21 --duration PT1H --stdout \
|
|
122
|
+
navigation.speedOverGround
|
|
123
|
+
|
|
124
|
+
# Simple moving average (5 samples), narrowed to one value column
|
|
125
|
+
python -m signalk_cli.history query --host 10.36.10.21 --duration PT1H \
|
|
126
|
+
--agg sma --samples 5 \
|
|
127
|
+
navigation.speedOverGround
|
|
128
|
+
|
|
129
|
+
# EMA with alpha 0.2
|
|
130
|
+
python -m signalk_cli.history query --host 10.36.10.21 --duration PT1H \
|
|
131
|
+
--agg ema --alpha 0.2 \
|
|
132
|
+
navigation.speedOverGround
|
|
133
|
+
|
|
134
|
+
# Inline spec — path:method, multiple paths with different methods
|
|
135
|
+
python -m signalk_cli.history query --host 10.36.10.21 --duration PT1H --stdout \
|
|
136
|
+
'navigation.speedOverGround:max' 'navigation.courseOverGroundTrue:average'
|
|
137
|
+
|
|
138
|
+
# Multiple literal paths, 1-minute resolution
|
|
139
|
+
python -m signalk_cli.history query --host 10.36.10.21 --duration PT1H --resolution 1m \
|
|
140
|
+
navigation.speedOverGround navigation.courseOverGroundTrue
|
|
141
|
+
|
|
142
|
+
# All navigation paths, specific date range, write to named file
|
|
143
|
+
python -m signalk_cli.history query --host 10.36.10.21 \
|
|
144
|
+
--from 2026-05-26T00:00:00Z --to 2026-05-27T00:00:00Z \
|
|
145
|
+
--output may26.csv \
|
|
146
|
+
'navigation\..*'
|
|
147
|
+
|
|
148
|
+
# Glob wildcard — all paths for the last 30 minutes as Feather
|
|
149
|
+
python -m signalk_cli.history query --host 10.36.10.21 --duration PT30M --format feather '*'
|
|
150
|
+
|
|
151
|
+
# Extension auto-selects feather format
|
|
152
|
+
python -m signalk_cli.history query --host 10.36.10.21 --duration PT1H \
|
|
153
|
+
-o out.feather navigation.speedOverGround
|
|
154
|
+
|
|
155
|
+
# Write to both a file and stdout
|
|
156
|
+
python -m signalk_cli.historyquery --host 10.36.10.21 --duration PT1H \
|
|
157
|
+
--output out.csv --stdout navigation.speedOverGround
|
|
158
|
+
|
|
159
|
+
# Duration in seconds, suppress header, pipe to another tool
|
|
160
|
+
python -m signalk_cli.history query --host 10.36.10.21 --duration 3600 --no-header --stdout \
|
|
161
|
+
navigation.speedOverGround | cut -d, -f1,3
|
|
162
|
+
|
|
163
|
+
# --bare: pure CSV output, no informational noise — pipe-friendly
|
|
164
|
+
python -m signalk_cli.history query --host 10.36.10.21 --duration PT1H --bare \
|
|
165
|
+
navigation.speedOverGround | awk -F, 'NR>1 {print $2, $3}'
|
|
166
|
+
|
|
167
|
+
# Different context
|
|
168
|
+
python -m signalk_cli.history query --host 10.36.10.21 --duration PT1H -c vessels.urn:mrn:imo:mmsi:123456789 \
|
|
169
|
+
navigation.speedOverGround
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
### `list-paths`
|
|
175
|
+
|
|
176
|
+
List all SignalK paths that have recorded data in a given time range.
|
|
177
|
+
|
|
178
|
+
```
|
|
179
|
+
python -m signalk_cli.history list-paths [OPTIONS]
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
Outputs one path per line to stdout. Defaults to the last hour if no time range is given. Accepts the same `--from`/`--to`/`--duration`, `--provider`/`--no-cache`, `-c/--context`, and `--bare` options as `query`.
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
# Paths recorded in the last hour
|
|
186
|
+
python -m signalk_cli.history list-paths --host 10.36.10.21
|
|
187
|
+
|
|
188
|
+
# Paths available on a specific day
|
|
189
|
+
python -m signalk_cli.historylist-paths --host 10.36.10.21 \
|
|
190
|
+
--from 2026-05-26T00:00:00Z --to 2026-05-27T00:00:00Z
|
|
191
|
+
|
|
192
|
+
# Pipe into grep
|
|
193
|
+
python -m signalk_cli.history list-paths --host 10.36.10.21 --duration PT24H | grep navigation
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
### `list-providers`
|
|
199
|
+
|
|
200
|
+
List all registered history provider plugins and identify the default. Supports `--bare` to suppress the "Server:" and provider-count lines.
|
|
201
|
+
|
|
202
|
+
```
|
|
203
|
+
python -m signalk_cli.history list-providers --host 10.36.10.21
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Example output:
|
|
207
|
+
|
|
208
|
+
```
|
|
209
|
+
kip (default)
|
|
210
|
+
signalk-parquet
|
|
211
|
+
2 provider(s)
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
The default provider is used automatically when `--provider` is not specified on other commands. It is fetched once and cached in `~/.cache/signalk-cli/`.
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
### `list-contexts`
|
|
219
|
+
|
|
220
|
+
List SignalK contexts (vessels, aircraft, etc.) that have recorded data in a given time range.
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
python -m signalk_cli.history list-contexts [OPTIONS]
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
Defaults to the last hour if no time range is given.
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
python -m signalk_cli.history list-contexts --host 10.36.10.21
|
|
230
|
+
|
|
231
|
+
python -m signalk_cli.history list-contexts --host 10.36.10.21 \
|
|
232
|
+
--from 2026-05-26T00:00:00Z --to 2026-05-27T00:00:00Z
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
## Time range
|
|
238
|
+
|
|
239
|
+
All commands that query data accept the same three time parameters. At least one of `--from` or `--duration` must be provided (or the tool supplies a one-hour default).
|
|
240
|
+
|
|
241
|
+
| Parameter | Format | Examples |
|
|
242
|
+
|---|---|---|
|
|
243
|
+
| `--from` | ISO 8601 timestamp | `2026-05-26T00:00:00Z` |
|
|
244
|
+
| `--to` | ISO 8601 timestamp | `2026-05-27T00:00:00Z` |
|
|
245
|
+
| `--duration` | ISO 8601 duration or integer seconds | `PT1H`, `PT15M`, `3600` |
|
|
246
|
+
|
|
247
|
+
Typical combinations:
|
|
248
|
+
|
|
249
|
+
- `--duration PT1H` — last hour ending now
|
|
250
|
+
- `--from T --duration PT1H` — hour starting at T
|
|
251
|
+
- `--from T1 --to T2` — explicit range
|
|
252
|
+
- `--duration PT1H --to T` — hour ending at T
|
|
253
|
+
|
|
254
|
+
## Provider caching
|
|
255
|
+
|
|
256
|
+
The default history provider is fetched from the server once and cached per host in `~/.cache/signalk-history-cli/`. Pass `--no-cache` to force a fresh lookup, or `--provider <id>` to target a specific provider explicitly.
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "signalk-cli"
|
|
3
|
+
version = "1.0.0"
|
|
4
|
+
description = "Query the SignalK v2 History API and export data as CSV or Apache Arrow Feather"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.13"
|
|
7
|
+
license="Apache-2.0"
|
|
8
|
+
authors = [
|
|
9
|
+
{ name = "jey burrows", email = "jrb@rhizomatics.org.uk" }
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
keywords = ["signalk", "sailing", "marine", "nmea","boating"]
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Development Status :: 3 - Alpha",
|
|
15
|
+
"Environment :: Console",
|
|
16
|
+
"Natural Language :: English",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"Topic :: Scientific/Engineering",
|
|
19
|
+
"Programming Language :: Python",
|
|
20
|
+
"Programming Language :: Python :: 3.13",
|
|
21
|
+
"Programming Language :: Python :: 3.14"
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
dependencies = [
|
|
25
|
+
"click>=8.3.3",
|
|
26
|
+
"niquests>=2.28",
|
|
27
|
+
"pyarrow>=17.0",
|
|
28
|
+
"zeroconf>=0.149.16,<0.150.0",
|
|
29
|
+
]
|
|
30
|
+
[dependency-groups]
|
|
31
|
+
dev = [
|
|
32
|
+
"ruff>=0.15.0",
|
|
33
|
+
"pre-commit>=4.4.0",
|
|
34
|
+
"pytest>=9.0.0",
|
|
35
|
+
"pytest-mock>=3.15.0",
|
|
36
|
+
"pytest-cov>=7.0.0",
|
|
37
|
+
"pytest-xdist",
|
|
38
|
+
"coverage",
|
|
39
|
+
"icdiff",
|
|
40
|
+
"codespell"
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
[project.urls]
|
|
44
|
+
Homepage = "https://github.com/rhizomatics/signalk-cli"
|
|
45
|
+
Repository = "https://github.com/rhizomatics/signalk-cli"
|
|
46
|
+
|
|
47
|
+
[tool.bandit]
|
|
48
|
+
exclude_dirs = ["tests"]
|
|
49
|
+
|
|
50
|
+
[tool.ruff.format]
|
|
51
|
+
# Like Black, use double quotes for strings.
|
|
52
|
+
quote-style = "double"
|
|
53
|
+
|
|
54
|
+
# Like Black, indent with spaces, rather than tabs.
|
|
55
|
+
indent-style = "space"
|
|
56
|
+
|
|
57
|
+
# Like Black, respect magic trailing commas.
|
|
58
|
+
skip-magic-trailing-comma = false
|
|
59
|
+
|
|
60
|
+
# Like Black, automatically detect the appropriate line ending.
|
|
61
|
+
line-ending = "auto"
|
|
62
|
+
|
|
63
|
+
[tool.pytest.ini_options]
|
|
64
|
+
pythonpath = ["src", "."]
|
|
65
|
+
asyncio_mode = "auto"
|
|
66
|
+
testpaths = [
|
|
67
|
+
"tests",
|
|
68
|
+
]
|
|
69
|
+
norecursedirs = [
|
|
70
|
+
".git"
|
|
71
|
+
]
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
[tool.coverage.run]
|
|
75
|
+
branch = true
|
|
76
|
+
source = ["src"]
|
|
77
|
+
|
|
78
|
+
[tool.mypy]
|
|
79
|
+
mypy_path=["./src"]
|
|
80
|
+
|
|
81
|
+
[tool.uv]
|
|
82
|
+
compile-bytecode = true
|
|
83
|
+
managed = true
|
|
84
|
+
exclude-newer = "5 days"
|
|
85
|
+
add-bounds = "major"
|
|
86
|
+
|
|
87
|
+
[build-system]
|
|
88
|
+
requires = ["uv_build>=0.11.13,<0.12.0"]
|
|
89
|
+
build-backend = "uv_build"
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
[tool.uv.build-backend]
|
|
93
|
+
module-root = "src"
|
|
94
|
+
module-name = "signalk_cli"
|
|
95
|
+
|
|
96
|
+
[project.scripts]
|
|
97
|
+
myproj = "signalk_cli.history:cli"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""signalk_cli — Python clients and CLI for SignalK APIs."""
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"""Entry point for `python -m signalk` — lists supported API modules."""
|
|
2
|
+
|
|
3
|
+
print("Supported SignalK APIs:")
|
|
4
|
+
print(" signalk_cli.history — SignalK v2 History API")
|
|
5
|
+
print()
|
|
6
|
+
print("Usage: python -m signalk_cli.<api> [COMMAND] [OPTIONS]")
|
|
7
|
+
print(" python -m signalk_cli.history --help")
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"""signalk_cli.history — Python client and CLI for the SignalK v2 History API."""
|
|
2
|
+
|
|
3
|
+
from .history_api import (
|
|
4
|
+
HISTORY_BASE,
|
|
5
|
+
api_error,
|
|
6
|
+
apply_time_default,
|
|
7
|
+
expand_paths,
|
|
8
|
+
fetch_default_provider,
|
|
9
|
+
fetch_server_paths,
|
|
10
|
+
get_cached_provider,
|
|
11
|
+
normalise_host,
|
|
12
|
+
resolve_provider,
|
|
13
|
+
save_cached_provider,
|
|
14
|
+
)
|
|
15
|
+
from .output import extract_rows, write_csv, write_feather
|
|
16
|
+
|
|
17
|
+
__all__ = [
|
|
18
|
+
"HISTORY_BASE",
|
|
19
|
+
"api_error",
|
|
20
|
+
"apply_time_default",
|
|
21
|
+
"expand_paths",
|
|
22
|
+
"extract_rows",
|
|
23
|
+
"fetch_default_provider",
|
|
24
|
+
"fetch_server_paths",
|
|
25
|
+
"get_cached_provider",
|
|
26
|
+
"normalise_host",
|
|
27
|
+
"resolve_provider",
|
|
28
|
+
"save_cached_provider",
|
|
29
|
+
"write_csv",
|
|
30
|
+
"write_feather",
|
|
31
|
+
]
|