marcolivierarsenault / moonraker-home-assistant

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

Sensor for Last Print File & Last Print Duration #414

Closed turulix closed 1 month ago

turulix commented 2 months ago

Is your feature request related to a problem? Please describe.

I'm trying to send myself a discord message, whenever my print finishes like octoprint does. Currentlly i simply use print_duration.state and _filename.state which results in this: image

Describe your setup

Please describe your Printer setup, (especially software stack) Ender-3 Neo, Mainsail

Describe the solution you'd like

I want something that gives me the sate of the last print.

Additional context

- id: '1723558995614'
  alias: Ender3-Neo Finished Print
  description: ''
  trigger:
  - platform: state
    entity_id:
    - sensor.ender_3_neo_current_print_state
    from: printing
    to: complete
  condition: []
  action:
  - device_id: 18092016fea4cab2d4e30a6949e715bf
    domain: mobile_app
    type: notify
    title: 3D Druck Abgeschlossen
    message: Ender 3-Neo ist fertig mit drucken.
  - service: notify.dc_notification
    data:
      message: ''
      target:
      - '1002737271159660604'
      data:
        embed:
          title: '**Ender3-Neo Print Complete ✅**'
          description: '{% set ct = states.sensor.ender_3_neo_print_duration.state
            | float %} **File**: {{ states.sensor.ender_3_neo_filename.state | truncate(57,
            true) }}

            **Print Time**: {{ "%d" | format(ct // 60) }} hours {{ "%d" | format(int(ct
            % 60)) }} minutes {{ "%d" | format((ct % 60)*100 // 60) }} seconds

            [Check In With Quick View](http://192.168.179.26/)

            '
          color: 3066992
  mode: single
marcolivierarsenault commented 2 months ago

Here is how I do it

alias: 3D print done
description: ""
trigger:
  - platform: state
    entity_id:
      - sensor.state
    to: complete
    for:
      hours: 0
      minutes: 1
      seconds: 0
  - platform: state
    entity_id:
      - sensor.mainsail_current_print_state
    to: complete
condition: []
action:
  - device_id: 393ca61ac995ba9fe1e881162eb40821
    domain: mobile_app
    type: notify
    title: Impression terminée
    message: 3D Printer
mode: single
marcolivierarsenault commented 2 months ago

I am not sure what you want different

turulix commented 2 months ago

Sorry,

I want to be able to template the duration and the filename into the message aswell. But i have the problem, where once the state changes to complete, the print_duration and filename also get reset and i couldn't find a way to retreive the previous state

marcolivierarsenault commented 2 months ago

yeah, you will need to use the helper in home assistant, I don't want to come up with new sensor/info that is not part of native moonraker