As you can see they can be true of false.
I’m wanting to make an automation so that when its at the “Finishing” step it triggers off the automation to start monitoring the bed temp and when it cools down to a certian temp to power off the smart plug for the printer.
So it would look something like this, but somehow reading the tags. As all HAS shows is either “Operational”, “Printing” or “Offline after error”
alias: Turn Off 3d Printer on Completion
description: ''
trigger:
- platform: state
entity_id: sensor.octoprint_print_status
from: finishing
to: operational
condition:
- condition: numeric_state
entity_id: sensor.octoprint_bed_temperature
below: '100'
action:
- type: turn_off
device_id: 52827340280a69b02c7f20ba34739891
entity_id: switch.14606200f4cfa200b680
domain: switch
mode: single
So I guess I need some kinda trigger that can say if “sensor.octoprint_print_status” tag “finishing” = True, then do “action, turn off”
Those are attributes, you can trigger off those using a state trigger by providing the attribute field. It would help if you opened that entity in the developer tools → states panel so we could see the real YAML structure, the UI pop-up can hide details.
I’m going to guess that you want to change your trigger to something like this but may need tweak since I don’t know exactly what those attributes look like:
alias: Turn Off 3d Printer on Completion
description: ''
trigger:
- platform: state
entity_id: sensor.octoprint_print_status
attribute: Flags.finishing
to: true
condition:
- condition: numeric_state
entity_id: sensor.octoprint_bed_temperature
below: '100'
action:
- type: turn_off
device_id: 52827340280a69b02c7f20ba34739891
entity_id: switch.14606200f4cfa200b680
domain: switch
mode: single
You’re misunderstanding how the flow works. The automation you are suggesting will trigger when the status changes from “finishing” to “operational” (I assume you have those the wrong way around) and then will immediately check the condition as a one-off test. If your bed temperature is above 100 at that point (check your units: I think OctoPrint reports °C, and not many materials need a bed temp above 100°C!) the action will not run.
You should instead set it up to trigger on the bed temperature dropping below a threshold which clearly indicates it’s finished, and have the status as a condition just to double-check something hasn’t gone wrong with the temperature sensing.
Next time I print something I’ll check out what the sensors say and help out if you’ve not sorted it by then — in the interim, here’s the automation I use to send a notification of completion and probably cool enough to remove the piece, set up as I described above but using the completion state rather than the printer status:
- alias: Misc - OctoPrint finished
description: Sends a notification when a 3D print job is done.
id: 2e876101-0e83-4b5b-82f2-9fcdc9c06f4e
trigger:
- platform: numeric_state
entity_id: sensor.octoprint_actual_bed_temp
below: 35
condition:
- "{{ states('sensor.octoprint_job_percentage')|int == 100 }}"
action:
- service: notify.admin
data:
message: Your 3D print job has finished
title: Octoprint finished.
It only triggers Finishing for a few seconds before going back to Operational. Which is why I did that.
So I’m unsure if CentralCommandMike edit he did would work as “Finishing” would no longer be True when the Temp is reached for it to shutdown.
I am also trying to set it up so if the print finishes, and I start another print that it doesn’t shut it down on me , which is why I don’t want to just set a timer.
OK — so what are the conditions under which you want it to switch off? You’d typically need it to cool enough to remove the first piece before starting another print.
How does the automation I posted (but with switch-off instead of notification, and temperature adjusted as required) not fulfil your requirements?
I’m also wanting to see about adjusting the RGB Color on the Lamp next to it. Like…
alias: 3D Light Canceling
description: ''
trigger:
- platform: state
entity_id: sensor.octoprint_print_status
attribute: Flags.cancelling
to: 'true'
from: 'false'
condition: []
action:
- service: light.turn_on
data:
color_name: red
brightness_pct: 100
target:
device_id: 611b68666fa147d78caee807eddc02c7
mode: single
Since I just saw yours only was a message and not actually doing that shutdown, and the condition would that be I guess “Template” for the type in the UI?
Hm, I wonder if its because the value of Flags.finishing is an actual boolean and the state trigger expects strings?
Maybe if you do something like this instead:
alias: Turn Off 3d Printer on Completion
description: ''
trigger:
- platform: state
entity_id: sensor.octoprint_print_status
attribute: Flags.finishing
condition:
- condition: numeric_state
entity_id: sensor.octoprint_bed_temperature
below: '100'
- condition: template
value_template: '{{ trigger.to_state.attributes.Flags.finishing }}'
action:
- type: turn_off
device_id: 52827340280a69b02c7f20ba34739891
entity_id: switch.14606200f4cfa200b680
domain: switch
mode: single
That should trigger any time the Flags.finishing attribute changes and then the condition should keep it from proceeding to the action unless that flag is true.
Also would you mind sharing what the entity really looks like from dev tools? I can’t really be sure I got the attribute identifiers right since you only shared a screenshot of the entity pop-up. The YAML of the entity would help clear things up.
Yea I know. That was in the automation from the beginning.
I don’t know why, the author didn’t explain. I assumed they put it in for a reason so I’m not going to question it.
EDIT: After quoting the automation from the beginning I’m starting to wonder if the only thing wrong with the initial automation was a capitalization issue. In the last screenshot it looks like the Finishing state starts with a capital F, the author is using a lowercase one in the automation at the top
So it will trigger as soon as it sees it switch true for “Finishing”, then wait untill the bed temp cools down.
What if it switched True, for 1 second, then back to False. Would it then cancel waiting for the condition step to take efffect?
As per Mike’s comment in post 2, open the entity in the dev tools / states page and see how everything is labelled in there. Just click on the entity id of the printer and it should display the attributes etc at the top of the page.
Were all just guessing because you’re sharing screenshots of the ui. The ui changes all sorts of things because it’s not for debugging/automating, it’s for human beings to look at when they want to know what’s going on in their house.
Please provide the yaml of this entity from dev tools so we can know the real state of this thing and help define the automation accordingly