Commit d445ed5
Add s7 demo subcommand: live server exposing real host metrics
A runnable, demoable S7 PLC backed by your own machine. CPU %, memory %,
disk/network throughput, temperature and fan RPM write into well-known
DB1 offsets every couple of seconds; a writable DB2 block lets clients
(e.g. the ha-s7 Home Assistant integration) flip a lamp, set a
brightness, push a text message, and the demo prints each write with a
timestamp. Optional rich live display shows current sensor values and
scrolling write history in a full-screen dashboard.
Runs as `s7 demo --port 10102` after `pip install "python-snap7[cli,demo]"`.
psutil lives behind a new `demo` extra so the core install stays thin.
DB layout is documented in the module docstring (and mirrored in
constants) so users can copy-paste PLC4X tag addresses straight into a
Home Assistant config.
Platform notes: CPU temperature and fan speed report 0 where psutil has
no sensor backend (macOS, most containers) — intentional, not a bug.
Tests exercise the collector, sensor encoder, threshold BOOL derivation,
and control-write diffing without spinning up the server; end-to-end
server coverage already lives in test_s7_unified and would duplicate
work here.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 2d9d1b8 commit d445ed5
4 files changed
Lines changed: 592 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
143 | 178 | | |
144 | 179 | | |
145 | 180 | | |
| |||
0 commit comments