Looking for network printers to monitor with AppDaemon

I’ve got my app to monitor printers via snmp ready to test a little. Does anyone out there have any ethernet printers (wired or wireless), with snmp turned on that would like to try it out. AppDaemon is required.

I was looking at your code when I was installing the weather alert app and wanted to try this out.

I have a Brother B&W laser printer and an Epson Artisan 837 ink jet printer that are both on WiFi. I did an snmpwalk on both of them, but couldn’t make heads or tails on what the MIBS were reading. I did save the output though if you think it would help. I’d love to test this out.

Great,
I have the latest copy pushed out there. If they conform to the SNMP standards, then it “should” work. But since I only have HP’s this will be a great test. You are the first test, so let me know what works and what doesn’t. Thanks

It’s not trivial to set it up, but I’m pretty sure you are up to the task. It requires pysnmp which can be pulled down by pip and is a simple install.

Installation

  1. Copy this file our appdaemon application directory
  2. Make input_sliders in your ha configuration.yaml file as follows
    A. input_slider.Printername_markercolor
    input_slider.oshp1_black # happens to be a monochrome laserjet
    input_slider.dsp1hp_black # inkjet color printer black cartridge
    input_slider.dsp1hp_yellow # inkjet color printer yellow cartridge
    input_slider.dsp1hp_cyan # inkjet color printer cyan cartridge
    input_slider.dsp1yp_magenta # inkjet color printer magenta cartridge
    B. each input slider should have
    min value of 0
    max value of 100
    initial value of 0
    C. setup a group for each printer and put the input sliders associated with that printer in the group. Use the printer name as the group name.
    D. in your appdaemon.cfg file
    [printermonitor]
    module = printermonitor
    class = printermonitor
    PrinterAddresses = [“192.168.2.247”,“192.168.2.249”]
    E. Restart HA
    3. Requires
    A. pysnmp sudo pip install pysnmp

The naming of the input sliders and groups are critical since that’s how it ties the appdaemon code back to the HA objects. Eventually I hope to turn this in to a control so we won’t have to do this part.

My printer names are dsp1hp and ofhp1
Here are my configuration and group file entries
Configuration.yaml
dsp1hp_black:
name: “black ink”
initial: 0
min: 0
max: 100
step: 1
dsp1hp_cyan:
name: “cyan ink”
initial: 0
min: 0
max: 100
step: 1
dsp1hp_yellow:
name: “yellow ink”
initial: 0
min: 0
max: 100
step: 1
dsp1hp_magenta:
name: “magenta ink”
initial: 0
min: 0
max: 100
step: 1
ofhp1_black:
name: “black Toner”
initial: 0
min: 0
max: 100
step: 1

Group.yaml
dsp1hp:
view: no
entities:
- input_slider.dsp1hp_black
- input_slider.dsp1hp_cyan
- input_slider.dsp1hp_yellow
- input_slider.dsp1hp_magenta

ofhp1:
  view: no
  entities:
    - input_slider.ofhp1_black

Trying to get your app configured - but no luck…
Running hass.io 0.86.4 and AppDaemon as add-on - is that (AppDaemon as add.on) the problem?
Can post errorcode etc of course, if it should work :slight_smile:

this topic is 2 years old.
appdaemon has changed a lot since then.
there are no cfg files used anymore but yaml files.

i looked at the py file and i see that its adapted for AD 3.0, but i dont know if the config has changed.
if the config hasnt changed it should now be:

create a file called printermonitor.yaml and place it in the apps dir.
it should look like:

printermonitor:
  module: printermonitor
  class: printermonitor
  PrinterAddresses: [“192.168.2.247”,“192.168.2.249”]

Sure, the topic is two years old - but the GitHub repo was updated six days ago with a new version…
And it is the updated version and a config in a yaml-file I’ve been trying out :slight_smile:

(Always a dilemma between posting questions in a forum or making an issue at GitHub :slight_smile:)

Just wouldn’t waste everybodys time by posting lots of configuration and error logs if it was a basic matter of a “no, it’s absolutely incompatible”…

Will return with config and logs.

for me its also always difficult to know if someone is a complete noob that just follows whats in the topic or someone who looks a bit more. :wink:

chips in file documentation is a very outdated, so thats also hard to see if its still is configured the same.
i guess @turboc needs to give an answer to that.
but config and logs never hurt. and might give me a clue whats wrong.

@cbh it’s working for me. So can you post the error you are getting? Do you have pysnmp installed? Also, there are some changes to what’s out on git for Appdaemon 4.0 so I may need to make a few changes to make it compatible with both.

if pysnmp is needed it should be placed in a configuration file from the addon hassio

Installed pysnmp with sudo pip install pysnmp
Added this file https://github.com/turboc1208/printermonitor/blob/master/printermonitor.ppy (renamed to .py) to homeassistant\appdaemon\apps\printermonitor

Made printermonitor.yaml in the same folder:

printermonitor:
  module: printermonitor
  class: printermonitor
  PrinterAddresses: ["192.168.1.5"]
  PrinterGroups: group.hl_3070cw

Get this in the log:

INFO AppDaemon: App 'printermonitor' added
INFO AppDaemon: Adding /config/appdaemon/apps/printermonitor to module import path
INFO AppDaemon: Loading App Module: /config/appdaemon/apps/printermonitor/printermonitor.py
WARNING AppDaemon: ------------------------------------------------------------
WARNING AppDaemon: Unexpected error loading module: /config/appdaemon/apps/printermonitor/printermonitor.py:
WARNING AppDaemon: ------------------------------------------------------------
WARNING AppDaemon: Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/appdaemon/appdaemon.py", line 2026, in check_app_updates
    self.read_app(mod["name"], mod["reload"])
  File "/usr/lib/python3.6/site-packages/appdaemon/appdaemon.py", line 1809, in read_app
    self.modules[module_name] = importlib.import_module(module_name)
  File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 674, in exec_module
  File "<frozen importlib._bootstrap_external>", line 781, in get_code
  File "<frozen importlib._bootstrap_external>", line 741, in source_to_code
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/config/appdaemon/apps/printermonitor/printermonitor.py", line 50
    m4_include(/home/appdaemon/code/appdaemon/adlib_imports.pyi)
               ^
SyntaxError: invalid syntax

WARNING AppDaemon: Removing associated apps:
WARNING AppDaemon: ------------------------------------------------------------
WARNING AppDaemon: ------------------------------------------------------------
WARNING AppDaemon: Unexpected error during utility()
WARNING AppDaemon: ------------------------------------------------------------
WARNING AppDaemon: Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/appdaemon/appdaemon.py", line 2026, in check_app_updates
    self.read_app(mod["name"], mod["reload"])
  File "/usr/lib/python3.6/site-packages/appdaemon/appdaemon.py", line 1809, in read_app
    self.modules[module_name] = importlib.import_module(module_name)
  File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 674, in exec_module
  File "<frozen importlib._bootstrap_external>", line 781, in get_code
  File "<frozen importlib._bootstrap_external>", line 741, in source_to_code
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/config/appdaemon/apps/printermonitor/printermonitor.py", line 50
    m4_include(/home/appdaemon/code/appdaemon/adlib_imports.pyi)
               ^
SyntaxError: invalid syntax

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/appdaemon/appdaemon.py", line 1420, in utility
    await utils.run_in_executor(self.loop, self.executor, self.check_app_updates)
  File "/usr/lib/python3.6/site-packages/appdaemon/utils.py", line 125, in run_in_executor
    response = list(completed)[0].result()
  File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/lib/python3.6/site-packages/appdaemon/appdaemon.py", line 2038, in check_app_updates
    if self.app_config[app]["module"] == module:
TypeError: string indices must be integers

 WARNING AppDaemon: -----------------------------------------------------

Probably I’m just doing something pretty basic thing wrong - any help much appreciated :slight_smile:

No it’s nothing you were doing. I wasn’t intending for that version to be released. Let me put another version out there for you to pull. It will be a py version and I’ll update the docs.

Cool - thanks!
And no stress :slight_smile:

Try that now. There were some issues with AD4 that caused me to add some local functions to a library I have. I think I removed the right things and it should work. You will move the stuff from the cfg file into your apps.yaml now too.