This wiki is a companion to multiple home automation videos.
NOTE: The examples here are for illustration purposes. You MUST modify them to work with your Home Assistant instance. Entity id’s, automation id’s, etc all should be unique to your instance and will require modification to work correctly. Don’t just pop this into your automations.yaml expecting it to work. You will need to modify them for your needs. Check out the Discord #home-automations channel for assistance configuring.
Use Case
When a 3D Print completes, I want to hear a notification over Google Home.
Usage
sensor.octoprint_job_percentage
is used to determine the percentage complete of a 3D print job. When this value is over 99% we trigger annoucements on multiple Google Home devices. You can alter the percentage below by modifying the above: 99
value to whatever percentage you want to alert at. You can create multiple trigger notifications and receive notifications when your print is in various states.
When using this recipe, its critical you modify the device_id
and entity_id
correctly. You can obtain this information easiest by going to /config/devices/dashboard in your Home Assistant installation. From there locate your OctoPrint instance and go to the device page (click on the result in home assistant). Once that page opens you can click the + sign under the Automations block to create a new automation. Then simply choose the “Job Percentage value changes” under “Do something when…” this will open a new automation template with these values. Then click the 3 dots to the right of the new Trigger and select “Edit in Yaml” and you’ll see these values below (for your device).
device_id: 3542bf0a317bfc6cd79ccd5a8b9c0e0d
entity_id: sensor.octoprint_job_percentage
Recipe (Place in automations.yaml)
- id: "1647877585863"
alias: "OP: [X301-1] Print Complete"
mode: single
description: ""
trigger:
- type: value
platform: device
device_id: 3542bf0a317bfc6cd79ccd5a8b9c0e0d
entity_id: sensor.octoprint_job_percentage
domain: sensor
above: 99
condition: []
action:
- service: tts.cloud_say
data:
entity_id: media_player.office_display
message: "The 3D Print on the X301 #1 is complete. "
- service: tts.cloud_say
data:
entity_id: media_player.maker_space_speaker
message: "The 3D Print on the X301 #1 is complete. "
cache: false
- service: tts.cloud_say
data:
entity_id: media_player.family_room_display
message: "The 3D Print on the X301 #1 is complete. "
cache: false
Use Case
I want to hear a notification over Google Home when the 3D Printer State Changes.
Usage
sensor.octoprint_current_state
is used in the below example as the sensor of our Octoprint instance. You’ll need to install the OctoPrint Home Assistant Discovery plugin into Octoprint and then add the Octoprint Plugin to Home Assistant. After configuring both of these plugins you can add the following to your automations.yaml. In the example below we send the same messages to multiple devices across the home when the printer changes state from “Unavailable” to “Operational” to “Printing”, etc. These announcements happen shortly after the true printer state changes. There is often a 10-30 second lag between state changes and announcements.
Recipe (Place in automations.yaml)
- id: "1234567890"
alias: "OP: [My Printer] Current State"
description: ""
trigger:
- platform: state
entity_id:
- sensor.octoprint_current_state
condition: []
action:
- service: tts.cloud_say
data:
entity_id: media_player.office_display
message: "The [My Printer] is {{states('sensor.octoprint_current_state')}}."
cache: false
- service: tts.cloud_say
data:
entity_id: media_player.maker_space_speaker
message: "The [My Printer] is {{states('sensor.octoprint_current_state')}}."
cache: false
- service: tts.cloud_say
data:
entity_id: media_player.family_room_display
message: "The [My Printer] is {{states('sensor.octoprint_current_state')}}."
cache: false
Use Case
I want to shut the 3D Printer off 15 minutes after print is complete if I do not start another one.
Usage
This recipe will turn off a 3D printer connected to a controllable outlet 15 minutes after a 3D print finished on the printer. If you start another print however the timer will expire and the printer wont shut off as long as the 3D printer is printing.
Start by going to Home Assistant Helpers and adding a helper of the Timer type. Set the name and duration for your timer. You can configure it for 15 minutes (as in this recipe) or any amount of time after the printer has completed printing.
timer.x301_1_power_off_timer
in this recipe is the name of the timer you just created in the previous step. Update it for the name of your timer.
device_id: 3542bf0a317bfc6cd79ccd5a8b9c0e0d
entity_id: binary_sensor.octoprint_printing_2
This is the Octoprint sensor which indicates in this recipe your 3D printer that just finished. You should have this already setup from the other recipes on this page. Update this value for your specific printer.
entity_id: media_player.office_display
is the display used to announce that the printer is shutting off (optional part of this recipe, can be removed).
device_id: 05282b23ef86aa9a301bfa4f7c8d0552
entity_id: switch.x301_1_on_off
These entries are the device ID and entity ID of the controllable outlet.
Recipe (Place in automations.yaml)
- id: '1653672737615'
alias: Turn Off Power Idle
description: ''
trigger:
- platform: event
event_type: timer.finished
event_data:
entity_id: timer.x301_1_power_off_timer
condition:
- type: is_off
condition: device
device_id: 3542bf0a317bfc6cd79ccd5a8b9c0e0d
entity_id: binary_sensor.octoprint_printing_2
domain: binary_sensor
action:
- service: tts.cloud_say
data:
message: 'Shutting down the X301 #1, it has been idle for 15 minutes after a
successful print.'
entity_id: media_player.office_display
- type: turn_off
device_id: 05282b23ef86aa9a301bfa4f7c8d0552
entity_id: switch.x301_1_on_off
domain: switch
mode: single