Skip to content

Commit

Permalink
Add Power Off Timer
Browse files Browse the repository at this point in the history
  • Loading branch information
Ircama committed Nov 10, 2023
1 parent adb7dc5 commit cd7d4d0
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 20 deletions.
37 changes: 18 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,25 +263,25 @@ printer.write_first_ti_received_time(2000, 1, 2)
## Output example
Example of advanced printer status with an XP-205 printer:

```
```python
{'cartridge_information': [{'id': '0D081F172A0D04004C',
'ink_color': [1811, 'Black'],
'ink_quantity': 89,
'ink_quantity': 76,
'production_month': 8,
'production_year': 2013},
{'id': '15031D06230D080093',
'ink_color': [1814, 'Yellow'],
'ink_quantity': 77,
'ink_quantity': 69,
'production_month': 3,
'production_year': 2021},
{'id': '150317111905020047',
'ink_color': [1813, 'Magenta'],
'ink_quantity': 59,
'ink_quantity': 49,
'production_month': 3,
'production_year': 2021},
{'id': '14091716080501001D',
'ink_color': [1812, 'Cyan'],
'ink_quantity': 40,
'ink_quantity': 29,
'production_month': 9,
'production_year': 2020}],
'cartridges': ['18XL', '18XL', '18XL', '18XL'],
Expand All @@ -301,10 +301,10 @@ Example of advanced printer status with an XP-205 printer:
'last_printer_fatal_errors': ['08', 'F1', 'F1', 'F1', 'F1', '10'],
'printer_head_id': '...',
'printer_status': {'cancel_code': 'No request',
'ink_level': [(1, 0, 'Black', 'Black', 89),
(5, 3, 'Yellow', 'Yellow', 77),
(4, 2, 'Magenta', 'Magenta', 59),
(3, 1, 'Cyan', 'Cyan', 40)],
'ink_level': [(1, 0, 'Black', 'Black', 76),
(5, 3, 'Yellow', 'Yellow', 69),
(4, 2, 'Magenta', 'Magenta', 49),
(3, 1, 'Cyan', 'Cyan', 29)],
'jobname': 'Not defined',
'loading_path': 'fixed',
'maintenance_box_1': 'not full (0)',
Expand All @@ -313,7 +313,6 @@ Example of advanced printer status with an XP-205 printer:
'maintenance_box_reset_count_2': 0,
'paper_path': 'Cut sheet (Rear)',
'ready': True,
'replace_cartridge': '00000001',
'status': (4, 'Idle'),
'unknown': [('0x24', b'\x0f\x0f')]},
'serial_number': '...',
Expand All @@ -337,25 +336,25 @@ Example of advanced printer status with an XP-205 printer:
'MAC Address': '...',
'Model': 'EPSON XP-205 207 Series',
'Model short': 'XP-205 207 Series',
'Name': '....',
'Name': '...',
'Power Off Timer': '0.5 hours',
'Print input': 'Auto sheet feeder',
'Total printed pages': '0',
'UpTime': '00:57:48',
'WiFi': '....',
'UpTime': '00:02:08',
'WiFi': '...',
'device_id': 'MFG:EPSON;CMD:ESCPL2,BDC,D4,D4PX,ESCPR1;MDL:XP-205 '
'207 Series;CLS:PRINTER;DES:EPSON XP-205 207 '
'Series;CID:EpsonRGB;FID:FXN,DPN,WFA,ETN,AFN,DAN;RID:40;',
'hex_data': 'A4 EE 57 DE FD 03'},
'Series;CID:EpsonRGB;FID:FXN,DPN,WFA,ETN,AFN,DAN;RID:40;'},
'stats': {'First TI received time': '...',
'Ink replacement cleaning counter': 78,
'Maintenance required level of 1st waste ink counter': 94,
'Maintenance required level of 2nd waste ink counter': 94,
'Manual cleaning counter': 129,
'Timer cleaning counter': 4,
'Total print page counter': 11504,
'Total print pass counter': 510136,
'Total scan counter': 4967},
'waste_ink_levels': {'borderless_waste': 4.63, 'main_waste': 90.45}}
'Total print page counter': 11569,
'Total print pass counter': 514602,
'Total scan counter': 4973},
'waste_ink_levels': {'borderless_waste': 4.72, 'main_waste': 90.8}}
```

## Resources
Expand Down
17 changes: 16 additions & 1 deletion epson_print_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ class EpsonPrinter:
"WiFi": "1.3.6.1.4.1.1248.1.1.3.1.29.2.1.9.0",
"MAC Addr": "1.3.6.1.4.1.1248.1.1.3.1.1.5.0",
"device_id": "1.3.6.1.4.1.11.2.3.9.1.1.7.0",
"Power Off Timer": "1.3.6.1.4.1.1248.1.2.2.44.1.1.2.1.111.116.2.0.1.1"
}

SNMP_OID_ENTERPRISE = "1.3.6.1.4.1"
Expand Down Expand Up @@ -1054,7 +1055,21 @@ def get_snmp_info(self, mib_name: str = None) -> str:
)
tag, result = self.snmp_mib(oid, label="get_snmp_info " + name)
logging.debug(" TAG: %s\n RESPONSE: %s", tag, repr(result))
if name == "hex_data" and result is not False:

if name == "Power Off Timer" and result and result.find(
b'@BDC PS\r\not:01') > 0:
try:
power_off_h = int.from_bytes(bytes.fromhex(
result[
result.find(b'@BDC PS\r\not:01') + 14
:
result.find(b';')
].decode()
), byteorder="little") / 60
sys_info[name] = f"{power_off_h} hours"
except Exception:
sys_info[name] = "(unknown)"
elif name == "hex_data" and result is not False:
sys_info[name] = result.hex(" ").upper()
elif name == "UpTime" and result is not False:
sys_info[name] = time.strftime(
Expand Down

0 comments on commit cd7d4d0

Please sign in to comment.