Skip to content

Commit 7dba2cd

Browse files
committed
mqtt tweak
2 parents 8f6753f + df55010 commit 7dba2cd

33 files changed

+1018
-304
lines changed

.flake8

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[flake8]
2+
max-line-length = 260
3+
per-file-ignores = __init__.py:F401
4+
exclude =
5+
.git,
6+
__pycache__,
7+
.tox,
8+
venv,
9+
.venv,
10+
build,
11+
dist,
12+
*.egg-info

.github/workflows/publish-to-pypi.yml

Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,45 +6,41 @@ jobs:
66
build:
77
name: Build distribution 📦
88
runs-on: ubuntu-latest
9-
109
steps:
11-
- uses: actions/checkout@v4
12-
- name: Set up Python
13-
uses: actions/setup-python@v4
14-
with:
15-
python-version: "3.x"
16-
- name: Install pypa/build
17-
run: >-
18-
python3 -m
19-
pip install
20-
build
21-
--user
22-
- name: Build a binary wheel and a source tarball
23-
run: python3 -m build
24-
- name: Store the distribution packages
25-
uses: actions/upload-artifact@v4
26-
with:
27-
name: python-package-distributions
28-
path: dist/
10+
- uses: actions/checkout@v4
11+
12+
- name: Install uv
13+
uses: astral-sh/setup-uv@v4
14+
15+
- name: Set up Python
16+
run: uv python install 3.13
17+
18+
- name: Build distribution
19+
run: uvx --from build pyproject-build --installer uv
20+
21+
- name: Store the distribution packages
22+
uses: actions/upload-artifact@v4
23+
with:
24+
name: python-package-distributions
25+
path: dist/
2926

3027
publish-to-pypi:
31-
name: >-
32-
Publish Python 🐍 distribution 📦 to PyPI
28+
name: Publish Python 🐍 distribution 📦 to PyPI
3329
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
3430
needs:
35-
- build
31+
- build
3632
runs-on: ubuntu-latest
3733
environment:
3834
name: pypi
39-
url: https://pypi.org/project/dashio # Replace <package-name> with your PyPI project name
35+
url: https://pypi.org/project/dashio
4036
permissions:
4137
id-token: write # IMPORTANT: mandatory for trusted publishing
42-
4338
steps:
44-
- name: Download all the dists
45-
uses: actions/download-artifact@v4
46-
with:
47-
name: python-package-distributions
48-
path: dist/
49-
- name: Publish distribution 📦 to PyPI
50-
uses: pypa/gh-action-pypi-publish@release/v1
39+
- name: Download all the dists
40+
uses: actions/download-artifact@v4
41+
with:
42+
name: python-package-distributions
43+
path: dist/
44+
45+
- name: Publish distribution 📦 to PyPI
46+
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/tests.yml

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,23 @@
11
name: Tests
2-
32
on:
43
- push
54
- pull_request
6-
75
jobs:
86
test:
97
runs-on: ${{ matrix.os }}
108
strategy:
119
matrix:
1210
os: [ubuntu-latest]
13-
python-version: ["3.8", "3.9", "3.10"]
14-
11+
python-version: ["3.10", "3.11", "3.12", "3.13"]
1512
steps:
16-
- uses: actions/checkout@v3
17-
- name: Set up Python ${{ matrix.python-version }}
18-
uses: actions/setup-python@v4
19-
with:
20-
python-version: ${{ matrix.python-version }}
21-
- name: Install dependencies
22-
run: |
23-
python -m pip install --upgrade pip
24-
pip install tox tox-gh-actions
25-
- name: Test with tox
26-
run: tox
13+
- uses: actions/checkout@v3
14+
- name: Install uv
15+
uses: astral-sh/setup-uv@v4
16+
with:
17+
enable-cache: false
18+
- name: Set up Python ${{ matrix.python-version }}
19+
run: uv python install ${{ matrix.python-version }}
20+
- name: Install tox
21+
run: uv tool install tox --with tox-uv
22+
- name: Run tests
23+
run: uvx tox

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ dmypy.json
133133
# End of https://www.gitignore.io/api/python
134134
.vscode/
135135
.VScode*
136-
*.ini
136+
Examples/*.ini
137137
.DS_Store
138138
pylint.out
139139
.noseids
@@ -148,4 +148,5 @@ scratch.py
148148
*_text.py
149149
*_test.py
150150
ttn.py
151-
a
151+
*.raw
152+
*.cvs

Documents/Documentation.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,7 @@ Feedback to the user of the dashboard is achieved when the IoT device responds t
497497
* *control_position : ControlPosition, optional.* The position of the control on a DeviceView, by default None.
498498
* *title_position : TitlePosition, optional.* Position of the title when displayed on the **Dash** app, by default None.
499499
* *column_no : int.* Optional default is 1. Must be 1..3. The Dash App reports its screen size in columns. column_no allows you to specify which column no to load into. Each control can store three configs that define how the device looks for Dash apps installed on single column phones or 2 column fold out phones or 3 column tablets.
500+
* *selection : list.* Optional. The selection list.
500501

501502
#### Selector Message Attributes
502503

Documents/dashio_data_exporter.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# How to Access Data from the DashIO Server
2+
3+
This guide explains how to retrieve data from the DashIO server for time graphs, maps, and logs using the utility `dashio_data_exporter` included in the dashio library package.
4+
5+
## Prerequisites
6+
7+
- Python 3
8+
- DashIO library package
9+
10+
## Installation
11+
12+
```bash
13+
pip3 install dashio
14+
```
15+
16+
The data retrieval script is included as a utility in the dashio package.
17+
18+
## Basic Usage
19+
20+
```bash
21+
python -m dashio.utilities.get_data -u USERNAME -p PASSWORD -d DEVICE_ID -c CONTROL_ID [options]
22+
```
23+
24+
## Command Line Arguments
25+
26+
| Argument | Description |
27+
|----------|-------------|
28+
| `-u`, `--username` | Your DashIO username |
29+
| `-p`, `--password` | Your DashIO password |
30+
| `-d`, `--device_id` | The ID of the device to access |
31+
| `-c`, `--control_id` | The ID of the control to access |
32+
| `-t`, `--type` | Control type: `TGRPH` (time graph), `MAP`, or `LOG` (default: `TGRPH`) |
33+
| `-n`, `--number_of_days` | Number of days of data to retrieve (default: 1) |
34+
| `-f`, `--format` | Output format: `raw` or `csv` (default: `raw`) |
35+
| `-s`, `--screen` | Display output to the screen |
36+
| `-o`, `--outfile` | Write output to file(s) |
37+
38+
## Examples
39+
40+
### Retrieving Time Graph Data
41+
42+
```bash
43+
python -m dashio.utilities.get_data -u myusername -p mypassword -d mydevice -c mygraph -t TGRPH -n 3 -s
44+
```
45+
46+
This retrieves 3 days of time graph data for the specified device and control, displaying the output on screen.
47+
48+
### Saving Map Data to a File
49+
50+
```bash
51+
python -m dashio.utilities.get_data -u myusername -p mypassword -d mydevice -c mymap -t MAP -f csv -o
52+
```
53+
54+
This retrieves map data in CSV format and saves it to a file.
55+
56+
### Getting Log Data
57+
58+
```bash
59+
python -m dashio.utilities.get_data -u myusername -p mypassword -d mydevice -c mylog -t LOG -s -o
60+
```
61+
62+
This retrieves log data, displaying it on screen and saving it to a file.
63+
64+
## Output File Naming
65+
66+
When using the `-o` option, files are named using the pattern:
67+
```
68+
[device_id]_[control_type]_[control_id]_[line_id].[format]
69+
```
70+
71+
## Understanding Output Formats
72+
73+
### Raw Format
74+
75+
The raw format preserves the original structure from the server with tab-separated values:
76+
```
77+
[device_id] [control_type] [control_id] [data...]
78+
```
79+
80+
### CSV Format
81+
82+
The CSV format converts time graph data to a more readable format:
83+
```
84+
# [device_id], TGRPH, [control_id], [line_id], [line_name], [line_type], [line_color], [line_axis]
85+
Timestamp, Value
86+
[timestamp], [value]
87+
[timestamp], [value]
88+
...
89+
```

README.md

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,23 @@ Dashio Phone | Dashio Tablet
5252

5353
## Install
5454

55-
`pip3 install dashio`
55+
### From PyPI (Recommended)
5656

57-
Or
57+
```sh
58+
pip3 install dashio
59+
```
60+
61+
### From Source
62+
63+
For development (editable install):
64+
65+
```sh
66+
git clone https://github.com/dashio-connect/python-dashio.git
67+
cd python-dashio
68+
pip3 install -e .
69+
```
70+
71+
For regular installation:
5872

5973
```sh
6074
git clone https://github.com/dashio-connect/python-dashio.git
@@ -193,7 +207,7 @@ while True:
193207

194208
We've added the cfg64 string. Then decoded it with *dashio.decode_cfg64(cfg64)*. This function returns a dictionary that we can pass into Device so that it can to instantiate and add the controls.
195209

196-
Included in the library are two commandline utilities to encode and decode cfg64 files.
210+
Included in the library are three commandline utilities to encode and decode cfg64 files, and to export data stored on the DashIO server.
197211

198212
```sh
199213
$ c64_decode -h
@@ -229,3 +243,28 @@ options:
229243
-w WIDTH, --width WIDTH
230244
Width of formatted output (Default 80).
231245
```
246+
247+
And
248+
249+
```sh
250+
$ dashio_data_exporter -h
251+
usage: dashio_data_exporter [-h] [-u USERNAME] [-p PASSWORD] [-d DEVICE_ID] [-c CONTROL_ID] [-t CONTROL_TYPE] [-n NUM_DAYS] [-f FORMAT] [-s] [-o]
252+
253+
options:
254+
-h, --help show this help message and exit
255+
-u, --username USERNAME
256+
DashIO Username
257+
-p, --password PASSWORD
258+
DashIO Password
259+
-d, --device_id DEVICE_ID
260+
The DeviceID of the device to get the data for.
261+
-c, --control_id CONTROL_ID
262+
The ControlID of the control on the device to get the data for.
263+
-t, --type CONTROL_TYPE
264+
Type of control, either 'TGRPH', 'MAP', 'LOG'.
265+
-n, --number_of_days NUM_DAYS
266+
Number of days of data to get up to present time.
267+
-f, --format FORMAT Format of the output data, either 'raw' or 'csv'.
268+
-s, --screen Write output to stdout.
269+
-o, --outfile Write output to file(s). The filename(s) are generated from the data.
270+
```

0 commit comments

Comments
 (0)