Octoprint automation helphub

Hello guys
i have y octoprint setup through Home assistant plug in.

i have main power source for my 3d printer and octoprint through sonoff mini flashed with Esphome
im trying to shutdown the printer and octoprint after the print finish and the nozzel temp reach below 50C. here is my automation

- id: '1600640307081'
  alias: Octoprint shutdown
  description: ''
  trigger:
  - platform: state
    entity_id: binary_sensor.octoprint_printing
    from: 'on'
    to: 'off'
  condition:
  - condition: numeric_state
    entity_id: sensor.octoprint_tool_0_temperature
    below: '50'
    attribute: unit_of_measurement
  action:
  - type: turn_off
    device_id: 96ede0813a3b4a04ad6b0caa4b3c619a
    entity_id: switch.octoprint_switch_switch
    domain: switch
  mode: restart

for some reason the automation is not working

any advice ?

We “advise” on your request for “advice”.

As far as I understand, this will only trigger once when Octoprint changes state.
Consider that the temperature when the printer finishes is 190 degrees; will this automation complete? No.
190 degrees is higher than 50 degrees.

You need a way to keep checking until the printer temperature reaches 50.

Not certain, but that is my interpretation of why it’s not working for you.

1 Like

You are correct thats the problem i have been trying to solve it but no luck ,should keep the trigger on for specific time ? or maybe another way to keep checking on condition?

I am certain there is a better way, but my intuition is that:

  • Set the trigger for when the printer drops below 50
  • Set the condition for when the printer goes from on to off in the last 30 minutes.

The 30 minutes is arbitrary as I don’t know what printer you have or what temperature you are printing at.

1 Like

Thanks very much

Just discovered that WAIT TEMPLATE in action will do the job
I will leave this post in case someone else face the same problem.

It would be better if you left the automation you used if you want to help others.

With the release of 0.115 you can now use the “Wait for Trigger” option.

That means you could do the following (based off the posted automation):

- id: '1600640307081'
  alias: Octoprint shutdown
  description: ''
  trigger:
  - platform: state
    entity_id: binary_sensor.octoprint_printing
    from: 'on'
    to: 'off'
  action:
  - wait_for_trigger:
    - platform: numeric_state
      entity_id: sensor.octoprint_tool_0_temperature
      below: '50'
      attribute: unit_of_measurement
    timeout: 600 # 10 minutes
  - type: turn_off
    device_id: 96ede0813a3b4a04ad6b0caa4b3c619a
    entity_id: switch.octoprint_switch_switch
    domain: switch
  mode: restart

* untested automation

1 Like

Planing on doing that when i finish the automation but for people sack i already mentioned the solution which was wait for template not trigger
Thanks for sharing yours.

I misunderstood when you said “WAIT TEMPLATE”.
My apologies.

No worries, I just moved your automation around to fit the new flow!

here is my automation

- id: '1600675776107'
  alias: Octoprint Shutdown
  description: ''
  trigger:
  - platform: state
    entity_id: binary_sensor.octoprint_printing
    from: 'on'
    to: 'off'
  condition: []
  action:
  - wait_template: '{{ states(''sensor.octoprint_actual_tool0_temp_c'')|int < 45 }}'
  - service: rest_command.shutdown_octoprint
    data: {}
  - delay: 00:02:00
  - type: turn_off
    device_id: 96ede0813a3b4a04ad6b0caa4b3c619a
    entity_id: switch.octoprint_switch_switch
    domain: switch
  mode: restart
1 Like