2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-10-14 21:22:20 +00:00

Machine properties and periodic ping (#10381)

* add machine properties

* remove non working polyfill

* add periodic task

* add tests and docs

* fix ping task

* add int and float type

* Update api_version.py

---------

Co-authored-by: Matthias Mair <code@mjmair.com>
This commit is contained in:
Lukas
2025-10-06 00:01:53 +02:00
committed by GitHub
parent 2e7e8d5eee
commit 66a488b6a2
18 changed files with 343 additions and 35 deletions

View File

@@ -107,6 +107,7 @@ The machine type class gets instantiated for each machine on server startup and
- check_setting
- set_status
- set_status_text
- set_properties
### Drivers
@@ -152,6 +153,7 @@ class MyXyzAbcDriverPlugin(MachineDriverMixin, InvenTreePlugin):
- init_machine
- update_machine
- restart_machine
- ping_machines
- get_machines
- handle_error
@@ -224,3 +226,24 @@ class MyXYZDriver(ABCBaseDriver):
# ... do some init stuff here
machine.set_status_text("Paper missing")
```
### Machine Properties
Machine properties such as the device model, firmware version, and total pages printed can be displayed in the machine detail drawer to provide users with relevant device information.
To achieve this, use the `machine.set_properties` function to set the desired properties. This can be combined with a periodic task, such as `ping_machines`, to keep the information up to date.
```py
from plugin.machine import MachineProperty
class MyXYZDriver(ABCBaseDriver):
# ...
def ping_machines(self):
for machine in self.get_machines():
# ... fetch machine info
props: list[MachineProperty] = [
{ 'key': 'Model', 'value': 'ABC' },
]
machine.set_properties(props)
```

View File

@@ -243,6 +243,12 @@ Refer to the [return order settings](../sales/return_order.md#return-order-setti
{{ globalsetting("ENABLE_PLUGINS_INTERFACE") }}
{{ globalsetting("ENABLE_PLUGINS_MAILS") }}
### Machine Settings
| Name | Description | Default | Units |
| ---- | ----------- | ------- | ----- |
{{ globalsetting("MACHINE_PING_ENABLED") }}
### Project Codes
Refer to the [project code settings](../concepts/project_codes.md).