marcolivierarsenault / moonraker-home-assistant

Home Assistant integration for Moonraker, Klipper and Mainsail
https://moonraker-home-assistant.readthedocs.io
MIT License
243 stars 26 forks source link

Disable moonraker polling when printer is off? Or some way to turn off HA logging? #276

Closed den-mac closed 6 months ago

den-mac commented 8 months ago

When my printer is off I get lots and lots of these in the HA logs:

2024-02-12 19:43:38.123 WARNING (MainThread) [custom_components.moonraker] connection to moonraker down, restarting 2024-02-12 19:43:41.185 ERROR (MainThread) [moonraker_api.websockets.websocketclient] Websocket connection error: Cannot connect to host 192.168.220.135:7125 ssl:default [Connect call failed ('192.168.220.135', 7125)]

I wish I could disable those messages. This does NOT work in the config yaml:

`recorder: purge_keep_days: 60 exclude: entity_globs:

Any ideas?

Unfortunately it looks like I can't use an automation to disable / enable an integration. I'll manually disable/enable it for now.

cashew22 commented 8 months ago

We could be more relax on the logging for sure.

*Note to self: Check for power switch if available and do not poll for nothing

marcolivierarsenault commented 8 months ago

we have to poll every x second because we can't detect when it's back, but we could manage logging differently

den-mac commented 8 months ago

ahhh this is ridiculous. If I forget to disable the integration it gets very spammy...

I wish there was a way to disable these somehow - I don't care if it can't connect because the printer is off most of the time...

2024-02-14 05:51:23.296 ERROR (MainThread) [moonraker_api.websockets.websocketclient] Websocket connection error: Cannot connect to host 192.168.220.135:7125 ssl:default [Connect call failed ('192.168.220.135', 7125)] 2024-02-14 05:51:53.223 WARNING (MainThread) [custom_components.moonraker] connection to moonraker down, restarting 2024-02-14 05:51:56.290 ERROR (MainThread) [moonraker_api.websockets.websocketclient] Websocket connection error: Cannot connect to host 192.168.220.135:7125 ssl:default [Connect call failed ('192.168.220.135', 7125)] 2024-02-14 05:52:26.223 WARNING (MainThread) [custom_components.moonraker] connection to moonraker down, restarting 2024-02-14 05:52:29.281 ERROR (MainThread) [moonraker_api.websockets.websocketclient] Websocket connection error: Cannot connect to host 192.168.220.135:7125 ssl:default [Connect call failed ('192.168.220.135', 7125)] 2024-02-14 05:52:59.223 WARNING (MainThread) [custom_components.moonraker] connection to moonraker down, restarting 2024-02-14 05:53:02.305 ERROR (MainThread) [moonraker_api.websockets.websocketclient] Websocket connection error: Cannot connect to host 192.168.220.135:7125 ssl:default [Connect call failed ('192.168.220.135', 7125)] 2024-02-14 05:53:32.225 WARNING (MainThread) [custom_components.moonraker] connection to moonraker down, restarting 2024-02-14 05:53:35.297 ERROR (MainThread) [moonraker_api.websockets.websocketclient] Websocket connection error: Cannot connect to host 192.168.220.135:7125 ssl:default [Connect call failed ('192.168.220.135', 7125)] 2024-02-14 05:54:05.222 WARNING (MainThread) [custom_components.moonraker] connection to moonraker down, restarting 2024-02-14 05:54:08.292 ERROR (MainThread) [moonraker_api.websockets.websocketclient] Websocket connection error: Cannot connect to host 192.168.220.135:7125 ssl:default [Connect call failed ('192.168.220.135', 7125)]

den-mac commented 8 months ago

Going to look for other solutions - for me I ONLY use this for pushover notifications of print status (pause, complete) so I think there's got to be a better way.

bmos commented 8 months ago

One workaround is powering the SBC running Klipper separately from the printer's mainboard. Then the klipper server can stay online between prints. Still less power efficient than not, but a Pi's power use isn't that bad.

den-mac commented 8 months ago

I did think of that, and considered it, but I know with the Octopus offline I don't know if it will just show up when the printer is turned on and have the Pi recognize it or not. Probably since it's USB but Moonraker may not be happy because Klipper probably won't start with a live connection to the MCU. Not sure there.

But I'm exploring doing pushover notifications directly in Moonraker, like I used to do when I built the Voron. There's a long thread I startred on teamfdm about this, and someone wrote about doing it via Moonraker directly so that's what I implemented.

https://www.teamfdm.com/forums/topic/816-howto-pushover-notifications-for-completed-prints-to-your-phone/

BeHappy2021 commented 7 months ago

As a workaround I've added this to my configuration.yaml to suppress the messages:

logger:
  filters: 
    moonraker_api.websockets.websocketclient:  
      - ".*Websocket connection error.*"
    custom_components.moonraker:
      - ".*connection to moonraker down, restarting.*"
      - ".*Error requesting moonraker data.*"
marcolivierarsenault commented 6 months ago

This won't get fix until we move to V2 (push)

In the meantime, you can use the fix proposed by @BeHappy2021 ☝️

den-mac commented 6 months ago

@BeHappy2021

I'd love to try your workaround but can't seem for the life of me to get the formatting correct. Can you paste in the exact code that needs to go into the config yaml?

I mean with indentation, etc.

den-mac commented 6 months ago

Oh hmm I think this is it...

logger:
  filters:
    moonraker_api.websockets.websocketclient:
      - ".*Websocket connection error.*"
    custom_components.moonraker:
      - ".*connection to moonraker down, restarting.*"
      - ".*Error requesting moonraker data.*"
BeHappy2021 commented 6 months ago

I've edited the post. I'd used a single ` instead of three. I think it was late when I posted it!

guix77 commented 3 months ago

@marcolivierarsenault This should be in a postponed status, not closed.