Custom Component - HP Printer

sh*** my fault. It is available. sorry for that and thanks for your work :slight_smile:

Is there a possibility to put the printer off ?

What do you mean?

The only thing I want from my printer is to check the ink ( that was already ok) and the possibility to use a switch to get the printer off

Hi. I have two printers HP LaserJet M401dne and HP Color LaserJet Pro M477fdw. I move to beta intergration 2.0b2 and now my prionters no working. On version 1 stable works with no problem. Whre is an issue ?When try add again i get error no support API.

Seems thaht prefetch api is not available, trying to understand why…
If you can provide har file or screenshot of network from developer tools in your browser when accessing the web server of the printer it can assist a lot,
Since it works with v1 of integration i expect to see there at least the endpoints v1 is using, v2 is using prefetch endpoint before to get list of all xml configurations (that 3 of them are being used in v1).

Thanks

Since update to 2024.5 my log file started to be flooded with following error:

2024-05-02 08:59:07.260 WARNING (SyncWorker_26) [homeassistant.helpers.frame] Detected that custom integration 'hpprinter' calls async_create_task from a thread at custom_components/hpprinter/managers/home_assistant.py, line 46: self._hass.async_create_task(self.async_update(now)), please report it to the author of the 'hpprinter' custom integration
2024-05-02 08:59:07.260 ERROR (MainThread) [homeassistant] Error doing job: Future exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/hpprinter/managers/home_assistant.py", line 46, in update_entities
    self._hass.async_create_task(self.async_update(now))
  File "/usr/src/homeassistant/homeassistant/core.py", line 816, in async_create_task
    self.verify_event_loop_thread("async_create_task")
  File "/usr/src/homeassistant/homeassistant/core.py", line 440, in verify_event_loop_thread
    frame.report(
  File "/usr/src/homeassistant/homeassistant/helpers/frame.py", line 162, in report
    _report_integration(what, integration_frame, level, error_if_integration)
  File "/usr/src/homeassistant/homeassistant/helpers/frame.py", line 203, in _report_integration
    raise RuntimeError(
RuntimeError: Detected that custom integration 'hpprinter' calls async_create_task from a thread at custom_components/hpprinter/managers/home_assistant.py, line 46: self._hass.async_create_task(self.async_update(now)). Please report it to the author of the 'hpprinter' custom integration.

Though it looks that integration as such works and I get all sensors populated. Any idea how to get rid of these errors?

I need to release new version to fix it,
have a backlog of integrations i need to work on this weekend due to this breaking change in HA,
will try my best to release it as soon as possible,
for now, you can disable the integration to avoid all the errors, i personally not upgrading HA up until i will fix all my integrations

btw, which version are you using? v1.x or beta version?
asking because beta version might work well, didn’t have the time to check it yet

I’m on 1.0.12, so seems the latest stable.

Can you pls check if beta version is working for you?

Thanks

Installed latest beta and these recurring errors are now gone. Instead now I see these:

2024-05-02 11:57:01.248 WARNING (MainThread) [custom_components.hpprinter.managers.ha_config_manager] Translations not found, Key: component.hpprinter.entity.sensor.main_manufacture_at.name, Entity: manufacture_at
2024-05-02 11:57:01.249 WARNING (MainThread) [custom_components.hpprinter.managers.ha_config_manager] Translations not found, Key: component.hpprinter.entity.binary_sensor.main_registration_state.name, Entity: registration_state
2024-05-02 11:57:01.249 WARNING (MainThread) [custom_components.hpprinter.managers.ha_config_manager] Translations not found, Key: component.hpprinter.entity.binary_sensor.main_cloud_services_switch_status.name, Entity: cloud_services_switch_status
2024-05-02 11:57:01.251 WARNING (MainThread) [custom_components.hpprinter.managers.ha_config_manager] Translations not found, Key: component.hpprinter.entity.sensor.consumable_consumable_station.name, Entity: consumable_station
2024-05-02 11:57:01.251 WARNING (MainThread) [custom_components.hpprinter.managers.ha_config_manager] Translations not found, Key: component.hpprinter.entity.sensor.consumable_consumable_type_enum.name, Entity: consumable_type_enum
2024-05-02 11:57:01.251 WARNING (MainThread) [custom_components.hpprinter.managers.ha_config_manager] Translations not found, Key: component.hpprinter.entity.sensor.consumable_consumable_percentage_level_remaining.name, Entity: consumable_percentage_level_remaining
2024-05-02 11:57:01.251 WARNING (MainThread) [custom_components.hpprinter.managers.ha_config_manager] Translations not found, Key: component.hpprinter.entity.sensor.consumable_refilled_count_counterfeit_refilled_count.name, Entity: refilled_count_counterfeit_refilled_count
2024-05-02 11:57:01.251 WARNING (MainThread) [custom_components.hpprinter.managers.ha_config_manager] Translations not found, Key: component.hpprinter.entity.sensor.consumable_refilled_count_genuine_refilled_count.name, Entity: refilled_count_genuine_refilled_count
2024-05-02 11:57:01.256 WARNING (MainThread) [custom_components.hpprinter.managers.ha_config_manager] Translations not found, Key: component.hpprinter.entity.binary_sensor.consumable_consumable_life_state_consumable_state.name, Entity: consumable_life_state_consumable_state
2024-05-02 11:57:01.257 WARNING (MainThread) [custom_components.hpprinter.managers.ha_config_manager] Translations not found, Key: component.hpprinter.entity.sensor.consumable_consumable_station.name, Entity: consumable_station
2024-05-02 11:57:01.257 WARNING (MainThread) [custom_components.hpprinter.managers.ha_config_manager] Translations not found, Key: component.hpprinter.entity.sensor.consumable_consumable_type_enum.name, Entity: consumable_type_enum
2024-05-02 11:57:01.257 WARNING (MainThread) [custom_components.hpprinter.managers.ha_config_manager] Translations not found, Key: component.hpprinter.entity.sensor.consumable_consumable_percentage_level_remaining.name, Entity: consumable_percentage_level_remaining
2024-05-02 11:57:01.257 WARNING (MainThread) [custom_components.hpprinter.managers.ha_config_manager] Translations not found, Key: component.hpprinter.entity.sensor.consumable_refilled_count_counterfeit_refilled_count.name, Entity: refilled_count_counterfeit_refilled_count
2024-05-02 11:57:01.257 WARNING (MainThread) [custom_components.hpprinter.managers.ha_config_manager] Translations not found, Key: component.hpprinter.entity.sensor.consumable_refilled_count_genuine_refilled_count.name, Entity: refilled_count_genuine_refilled_count
2024-05-02 11:57:01.260 WARNING (MainThread) [custom_components.hpprinter.managers.ha_config_manager] Translations not found, Key: component.hpprinter.entity.binary_sensor.consumable_consumable_life_state_consumable_state.name, Entity: consumable_life_state_consumable_state
2024-05-02 11:57:01.261 WARNING (MainThread) [custom_components.hpprinter.managers.ha_config_manager] Translations not found, Key: component.hpprinter.entity.sensor.printer_total_impressions.name, Entity: total_impressions
2024-05-02 11:57:01.261 WARNING (MainThread) [custom_components.hpprinter.managers.ha_config_manager] Translations not found, Key: component.hpprinter.entity.sensor.printer_jam_events.name, Entity: jam_events
2024-05-02 11:57:01.261 WARNING (MainThread) [custom_components.hpprinter.managers.ha_config_manager] Translations not found, Key: component.hpprinter.entity.sensor.printer_mispick_events.name, Entity: mispick_events
2024-05-02 11:57:01.263 WARNING (MainThread) [custom_components.hpprinter.managers.ha_config_manager] Translations not found, Key: component.hpprinter.entity.sensor.scanner_scan_images.name, Entity: scan_images
2024-05-02 11:57:01.263 WARNING (MainThread) [custom_components.hpprinter.managers.ha_config_manager] Translations not found, Key: component.hpprinter.entity.sensor.scanner_adf_images.name, Entity: adf_images
2024-05-02 11:57:01.263 WARNING (MainThread) [custom_components.hpprinter.managers.ha_config_manager] Translations not found, Key: component.hpprinter.entity.sensor.scanner_jam_events.name, Entity: jam_events
2024-05-02 11:57:01.263 WARNING (MainThread) [custom_components.hpprinter.managers.ha_config_manager] Translations not found, Key: component.hpprinter.entity.sensor.scanner_mispick_events.name, Entity: mispick_events
2024-05-02 11:57:01.266 WARNING (MainThread) [custom_components.hpprinter.managers.ha_config_manager] Translations not found, Key: component.hpprinter.entity.sensor.copy_total_impressions.name, Entity: total_impressions
2024-05-02 11:57:01.266 WARNING (MainThread) [custom_components.hpprinter.managers.ha_config_manager] Translations not found, Key: component.hpprinter.entity.sensor.copy_adf_images.name, Entity: adf_images
2024-05-02 11:57:01.266 WARNING (MainThread) [custom_components.hpprinter.managers.ha_config_manager] Translations not found, Key: component.hpprinter.entity.sensor.copy_monochrome_impressions.name, Entity: monochrome_impressions
2024-05-02 11:57:01.266 WARNING (MainThread) [custom_components.hpprinter.managers.ha_config_manager] Translations not found, Key: component.hpprinter.entity.sensor.copy_color_impressions.name, Entity: color_impressions

Though these are not repeating, occured only once at system start.

just making sure, with v2.0.0b4 you are getting following errors?
can you pelase remove the integration and re-install it (using hacs),
it seems that there is mismatch of translation files.

thanks

Opss… that was 2.0.0b2… not sure why it was showing on the top of the list of available downloads…
So reinstalled and translation errors are gone… but now I see:

2024-05-02 21:49:34.413 WARNING (SyncWorker_3) [homeassistant.helpers.frame] Detected that custom integration 'hpprinter' calls async_create_task from a thread at custom_components/hpprinter/managers/home_assistant.py, line 46: self._hass.async_create_task(self.async_update(now)), please report it to the author of the 'hpprinter' custom integration
2024-05-02 21:49:34.413 ERROR (MainThread) [homeassistant] Error doing job: Future exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/hpprinter/managers/home_assistant.py", line 46, in update_entities
    self._hass.async_create_task(self.async_update(now))
  File "/usr/src/homeassistant/homeassistant/core.py", line 816, in async_create_task
    self.verify_event_loop_thread("async_create_task")
  File "/usr/src/homeassistant/homeassistant/core.py", line 440, in verify_event_loop_thread
    frame.report(
  File "/usr/src/homeassistant/homeassistant/helpers/frame.py", line 162, in report
    _report_integration(what, integration_frame, level, error_if_integration)
  File "/usr/src/homeassistant/homeassistant/helpers/frame.py", line 203, in _report_integration
    raise RuntimeError(
RuntimeError: Detected that custom integration 'hpprinter' calls async_create_task from a thread at custom_components/hpprinter/managers/home_assistant.py, line 46: self._hass.async_create_task(self.async_update(now)). Please report it to the author of the 'hpprinter' custom integration.
2024-05-02 21:49:34.414 WARNING (MainThread) [py.warnings] /usr/local/lib/python3.12/asyncio/base_events.py:1989: RuntimeWarning: coroutine 'HPPrinterHomeAssistant.async_update' was never awaited
  handle = None  # Needed to break cycles when an exception occurs.

2024-05-02 21:50:34.413 WARNING (SyncWorker_5) [homeassistant.helpers.frame] Detected that custom integration 'hpprinter' calls async_create_task from a thread at custom_components/hpprinter/managers/home_assistant.py, line 46: self._hass.async_create_task(self.async_update(now)), please report it to the author of the 'hpprinter' custom integration
2024-05-02 21:50:34.413 ERROR (MainThread) [homeassistant] Error doing job: Future exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/hpprinter/managers/home_assistant.py", line 46, in update_entities
    self._hass.async_create_task(self.async_update(now))
  File "/usr/src/homeassistant/homeassistant/core.py", line 816, in async_create_task
    self.verify_event_loop_thread("async_create_task")
  File "/usr/src/homeassistant/homeassistant/core.py", line 440, in verify_event_loop_thread
    frame.report(
  File "/usr/src/homeassistant/homeassistant/helpers/frame.py", line 162, in report
    _report_integration(what, integration_frame, level, error_if_integration)
  File "/usr/src/homeassistant/homeassistant/helpers/frame.py", line 203, in _report_integration
    raise RuntimeError(
RuntimeError: Detected that custom integration 'hpprinter' calls async_create_task from a thread at custom_components/hpprinter/managers/home_assistant.py, line 46: self._hass.async_create_task(self.async_update(now)). Please report it to the author of the 'hpprinter' custom integration.

That’s weird, more ppl complain about that error, but in v2.x, that file was removed and i’m not experiencing it,
Will try to reinstall older cersion and switch back to v2

Released new beta version v2.0.5,
v2.0.4 was created from master (non-beta) branch,
Hope that now it will work

Just installed and tested… All errors gone from log :slight_smile: BUT at the same time not all sensors are created… for me actually all that I use are unavailable after upgrade:

  • sensor.hp_printer_status
  • sensor.hp_printer_printer
  • sensor.hp_printer_inlcartridge_black
  • sensor.hp_printer_inkcartridge_cyanmagentayellow

Also some other seems to be unavailable now:

  • sensor.hp_printer_scanner
  • binary_sensor.hp_printer_connectivity

I reinstalled 2.0.4 and all of these sesnors become available again. Reinstalled 2.0.5 and again all sensors gone. Strnagely, these listed above are the only affected sensors, all other seems to be OK.

devices and entities changed dramatically in v2, there are much more and organized bit better.

main unit is hub of devices, device can be the sub-unit (printer, scanner, copier, fax or consumables - ink / toner).
per sub-unit and consumable, you can find the entities related to it.

hope it make sense :slight_smile:

My goal is to print a diagnostic page one week after the last print, to prevent the cartridges from drying. Question is: How to send the print? Looks like the integration does not support this. I know there are several possible ways to do it but wondering how others have implemented it. Currently I simply have a Windows scheduled task that prints at a fixed time every week using C:\Windows\System32\Printing_Admin_Scripts\en-US\prnqctl.vbs.

It’s already wip, but will take time,
Diagnostic print page consisted with many jobs available per printer (print test page, network status, calibration), all those jobs will be represented as button (per job type) under the main device

1 Like