easye4-python 1.0.0__py3-none-any.whl

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.

Potentially problematic release.


This version of easye4-python might be problematic. Click here for more details.

@@ -0,0 +1,251 @@
1
+ Metadata-Version: 2.4
2
+ Name: easye4-python
3
+ Version: 1.0.0
4
+ Summary: Python interface for the Eaton easyE4 JSON API
5
+ Author: Dennis Ulijn
6
+ License-Expression: MIT
7
+ Keywords: Eaton,easyE4,PLC,industrial automation,JSON API,Python
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Operating System :: OS Independent
10
+ Classifier: Topic :: System :: Hardware
11
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
12
+ Requires-Python: >=3.10
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Requires-Dist: requests>=2.31
16
+ Requires-Dist: python-dotenv>=1.0
17
+ Dynamic: license-file
18
+
19
+ # easyE4 Python Library
20
+
21
+ A reusable Python interface for the Eaton easyE4 JSON API. The library provides system information, digital and analog I/O reads, marker memory reads, and controlled marker writes without application-specific scaling or operand mappings.
22
+
23
+ **Status:** Development release 1.0.0. Tested with a physical easyE4 on firmware 2.46 (build 3603). This is an independently developed starter kit, not an official Eaton SDK.
24
+
25
+ ## Requirements
26
+
27
+ - Python 3.10 or newer
28
+ - Network access to an easyE4 with its webserver enabled
29
+ - Appropriate easySoft webserver settings and user permissions
30
+ - `requests` and `python-dotenv` (installed automatically with the package)
31
+
32
+ For reading I/O, enable **Read I/Os** in the easySoft webserver configuration. For writing markers, enable **marker write**, configure an allowed write range, and use an account with read/write rights. Transfer configuration changes to the device.
33
+
34
+ ## Installation
35
+
36
+ From the project root (the directory containing `pyproject.toml`):
37
+
38
+ ```powershell
39
+ python -m venv .venv
40
+ .venv\Scripts\Activate.ps1
41
+ python -m pip install -e .
42
+ ```
43
+
44
+ Editable installation is useful for development. To install a local copy non-editably, run `python -m pip install .`.
45
+
46
+ ## Configuration
47
+
48
+ Copy `.env.example` to `.env` in the project root and fill in your own values:
49
+
50
+ ```dotenv
51
+ EASYE4_IP=192.168.1.100
52
+ EASYE4_PORT=443
53
+ EASYE4_PROTOCOL=https
54
+ EASYE4_TIMEOUT=5
55
+ EASYE4_AUTH_METHOD=basic
56
+ EASYE4_USERNAME=
57
+ EASYE4_PASSWORD=
58
+ EASYE4_API_KEY=
59
+ EASYE4_CA_FILE=certificates/easyRootCertV1.crt
60
+ EASYE4_TLS_COMPATIBILITY=false
61
+ ```
62
+
63
+ - Supported authentication modes: `none`, `basic`, `bearer`.
64
+ - The CA path is resolved relative to the `.env` file when using `EasyE4.from_env()`.
65
+ - Do not commit `.env`, passwords, API keys, or private keys to version control.
66
+ - `from_env()` in this development version defaults to the package project's `.env`; for another location pass `EasyE4.from_env(env_file="path/to/.env")`.
67
+
68
+ ### TLS security
69
+
70
+ Normal certificate verification is the default. On the tested device, Python 3.13 reported `Missing Authority Key Identifier`. Setting `EASYE4_TLS_COMPATIBILITY=true` disables OpenSSL's extra `VERIFY_X509_STRICT` profile checks while retaining the intended CA and hostname verification. This is a **compatibility exception**, not the preferred production configuration. Validate certificate identity, trust, and security requirements before customer deployment. Never use `verify=False` as a routine workaround.
71
+
72
+ ## Quick start
73
+
74
+ ```python
75
+ from easye4 import EasyE4
76
+
77
+ with EasyE4.from_env() as easy:
78
+ connection = easy.connect()
79
+ print(connection)
80
+ print("State:", easy.get_state())
81
+ print("M1:", easy.read_marker(1))
82
+ print("MW1:", easy.read_word(1))
83
+ ```
84
+
85
+ The context manager closes the HTTP session automatically. `connect()` verifies communication using the firmware endpoint; it does not start or stop the PLC program.
86
+
87
+ ## Public API
88
+
89
+ ### Connection and system information
90
+
91
+ | Method | Purpose |
92
+ |---|---|
93
+ | `connect()` | Verify communication and authentication; return connection details |
94
+ | `disconnect()` | Close HTTP session |
95
+ | `is_connected()` | Check whether device responds now |
96
+ | `get_firmware()` | Return version and build |
97
+ | `get_state()` | Return RUN/STOP state |
98
+ | `get_device_name()` | Read configured device name |
99
+ | `get_program_name()` | Read program name |
100
+
101
+ ### Read I/O
102
+
103
+ | Method | Returns |
104
+ |---|---|
105
+ | `read_digital_input(index)` / `read_digital_inputs(indices)` | `I` bit(s), 0/1 |
106
+ | `read_digital_output(index)` / `read_digital_outputs(indices)` | `O` bit(s), 0/1 |
107
+ | `read_analog_input(index)` / `read_analog_inputs(indices)` | Raw signed 32-bit `AI` value(s) |
108
+ | `read_analog_output(index)` / `read_analog_outputs(indices)` | Raw signed 32-bit `AO` value(s) |
109
+ | `read_io(digital_inputs=..., digital_outputs=..., analog_inputs=..., analog_outputs=...)` | Combined I/O dictionary |
110
+
111
+ ### Marker memory
112
+
113
+ | Method | Purpose |
114
+ |---|---|
115
+ | `read_marker(index)` / `read_markers(indices)` | Read M bit(s) |
116
+ | `read_word(index)` | Read unsigned 16-bit MW |
117
+ | `read_dword(index)` | Read unsigned 32-bit MD |
118
+ | `read_memory(markers=..., words=..., dwords=...)` | Read selected M/MW/MD from one `MALL` response |
119
+ | `write_marker(index, value)` | Write 0 or 1 to an allowed M address |
120
+ | `write_word(index, value)` | Write 0..65535 to an allowed MW address |
121
+ | `read_snapshot(...)` | Combine selected I/O and marker-memory reads |
122
+
123
+ `read_snapshot()` accepts the four `read_io()` lists plus `markers`, `words`, and `dwords`. It uses up to five sequential HTTP requests, **not** an atomic PLC snapshot. A requested marker-memory group uses one request regardless of how many M/MW/MD values it selects.
124
+
125
+ ```python
126
+ with EasyE4.from_env() as easy:
127
+ easy.connect()
128
+ snapshot = easy.read_snapshot(
129
+ digital_inputs=[1, 2],
130
+ digital_outputs=[1, 2],
131
+ analog_inputs=[1, 2],
132
+ analog_outputs=[1],
133
+ markers=[1, 2],
134
+ words=[1, 2],
135
+ dwords=[1],
136
+ )
137
+ print(snapshot)
138
+ ```
139
+
140
+ **Raw data:** No engineering units or scale factors are applied. Interpret values according to the connected easySoft program. `M`, `MB`, `MW`, and `MD` overlap in the same memory: `MW1` contains the bits of `M1` through `M16`, and `MD1` covers `MW1` and `MW2`. Do not assign unrelated variables to overlapping addresses.
141
+
142
+ ## Writing safely
143
+
144
+ Writing requires explicit PLC permissions and an approved, noncritical operand. Even a short write can change machine behavior; restoring a value does not undo physical consequences. The interactive `09_write_markers.py` example asks for confirmation, verifies readback, and attempts restoration. Automatic restoration cannot be guaranteed after network or power loss.
145
+
146
+ ```python
147
+ # Only on a verified safe test address, with appropriate authorization.
148
+ with EasyE4.from_env() as easy:
149
+ easy.connect()
150
+ original = easy.read_marker(100)
151
+ # Inspect and confirm safety before calling easy.write_marker(...).
152
+ ```
153
+
154
+ ## Examples
155
+
156
+ Run from the project root, e.g. `python examples/01_connection.py`.
157
+
158
+ | File | Demonstrates | Writes to PLC? |
159
+ |---|---|---|
160
+ | `01_connection.py` | Connect and close | No |
161
+ | `02_system_info.py` | Firmware, state, names | No |
162
+ | `03_digital_inputs.py` | IALL diagnostic read | No |
163
+ | `04_digital_outputs.py` | OALL diagnostic read | No |
164
+ | `05_analog_inputs.py` | AIALL raw values | No |
165
+ | `06_analog_outputs.py` | AOALL raw values | No |
166
+ | `07_read_markers.py` | Single and multiple M reads | No |
167
+ | `08_read_words.py` | MW/MD, signed conversion and overlap | No |
168
+ | `09_write_markers.py` | Interactive M/MW write and restore | **Yes, after confirmation** |
169
+ | `10_combined_read.py` | `read_snapshot()` | No |
170
+ | `11_live_monitor.py` | Polling and change detection; Ctrl+C to stop | No |
171
+ | `12_error_handling.py` | Error scenarios (mostly mocks) | No |
172
+
173
+ Some diagnostic examples intentionally use the internal `easy.api._get_json()` interface to inspect device responses. Application code should prefer the public `EasyE4` methods.
174
+
175
+ ## Verified device response formats
176
+
177
+ | Request (`GET /api/get/data?elm=...`) | Response key | Decoded length |
178
+ |---|---|---:|
179
+ | `I` | `IALL` | 16 bytes |
180
+ | `O` | `OALL` | 16 bytes |
181
+ | `AI` | `AIALL` | 2048 bytes |
182
+ | `AO` | `AOALL` | 512 bytes |
183
+ | `M` | `MALL` | 128 bytes |
184
+
185
+ The physical device confirmed these response keys and sizes. The library decodes digital blocks bitwise (least-significant bit first) and analog blocks as signed little-endian 32-bit integers. **Exact physical channel-to-bit/index mapping has not been independently verified for every I/O channel.** Check against known hardware states before relying on a mapping in production.
186
+
187
+ For writes, the tested endpoint is `GET /api/set/op?op=M&index=...&val=...` or `op=MW`; a successful write returned HTTP **204 No Content**. A write response is not a substitute for readback verification.
188
+
189
+ ## Error handling
190
+
191
+ The current release uses built-in exceptions rather than dedicated library exception classes:
192
+
193
+ - `ConnectionError`: connection, timeout, TLS, or read authentication failures (inspect message).
194
+ - `PermissionError`: rejected write authorization (401/403).
195
+ - `ValueError`: invalid index/value, malformed response, or rejected write request (400).
196
+ - `OSError`: local file/system problems.
197
+
198
+ ```python
199
+ try:
200
+ with EasyE4.from_env() as easy:
201
+ easy.connect()
202
+ print(easy.read_marker(1))
203
+ except (ConnectionError, PermissionError, ValueError, OSError) as error:
204
+ print("easyE4 operation failed:", error)
205
+ ```
206
+
207
+ ## Troubleshooting
208
+
209
+ | Symptom | Check |
210
+ |---|---|
211
+ | Connection refused / timeout | IP, port, network, webserver enabled |
212
+ | HTTP 401 | Credentials and user rights; check read vs write permission |
213
+ | HTTP 400 or device `ERROR` | Operand category, index, write range and device documentation |
214
+ | No I/O data / operand error | **Enable Read I/Os** in easySoft and download configuration |
215
+ | Write rejected | **Enable marker (write)**, permitted range, read/write account |
216
+ | `Missing Authority Key Identifier` | Review CA/certificate; compatibility setting only for the verified device case |
217
+ | Unexpected M/MW/MD values | Check shared-memory overlap and PLC program writes |
218
+ | Zero values | May be valid; confirm PLC program and physical input/output states |
219
+
220
+ ## Tests and validation
221
+
222
+ The `tests/` directory contains mock-based tests for parsing, validation, connection and error handling. Examples were also exercised against a physical easyE4 firmware 2.46, build 3603. Tests using mocks do **not** prove all hardware address mappings or security behavior. Run regression tests after changing transport, TLS or decoders.
223
+
224
+ ## Known limitations and next improvements
225
+
226
+ - I/O index-to-physical-channel mappings need controlled hardware validation.
227
+ - TLS compatibility exception needs production security review and ideally compliant device certificates.
228
+ - `read_snapshot()` is sequential, not atomic.
229
+ - No dedicated exception hierarchy yet.
230
+ - No generic MD write method or asynchronous polling API in this version.
231
+ - The examples and API have not been certified for safety-critical or unattended control.
232
+
233
+ ## Project structure
234
+
235
+ ```text
236
+ easye4-python/
237
+ easye4/
238
+ __init__.py
239
+ api.py
240
+ client.py
241
+ examples/
242
+ 01_connection.py ... 12_error_handling.py
243
+ tests/
244
+ certificates/
245
+ .env.example
246
+ .gitignore
247
+ pyproject.toml
248
+ README.md
249
+ ```
250
+
251
+ For new applications, keep the library generic and place process-specific operand mappings, scaling, alarm logic, and logging in the consuming project.
@@ -0,0 +1,9 @@
1
+ easye4/__init__.py,sha256=1zE_2rfQdfMC00998J8EzMznbCqyF_dM6-eVrosWM14,146
2
+ easye4/api.py,sha256=g_4lBc_0trKYNEzStTSFUTITJwlGW7xKKv_A93d2rRQ,24314
3
+ easye4/client.py,sha256=TQNiSVRj4j_Y68V5jw0n9PIwtsjCmdpjejFfmg890e0,11421
4
+ easye4/certificates/easyRootCertV1.crt,sha256=XQtIJT2YBowCmg5MANLDXnN5aygSlXs2DtbsnABatIM,882
5
+ easye4_python-1.0.0.dist-info/licenses/LICENSE,sha256=1A01jEVyoX9z-VjkgGr69UGznKlUUeZh57uXB1EXn3U,1069
6
+ easye4_python-1.0.0.dist-info/METADATA,sha256=8yv8jA_I_VhZVQD6LHWaKnTofHHUB_CoVJwRTM-VKv8,11367
7
+ easye4_python-1.0.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
8
+ easye4_python-1.0.0.dist-info/top_level.txt,sha256=sBrQ_NyV5SPXLWLdL4FK0bAMN2HA8waTRqcFXzzUCIk,7
9
+ easye4_python-1.0.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Dennis Ulijn
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ easye4