diff --git a/lovelace/01_lights_view.yaml b/lovelace/01_lights_view.yaml
index e3faf8a..974f82f 100644
--- a/lovelace/01_lights_view.yaml
+++ b/lovelace/01_lights_view.yaml
@@ -36,7 +36,6 @@ cards:
title: Fragrance Outlets
show_header_toggle: true
entities:
- - switch.3d_printer
- switch.downstairs_fragrance
- switch.upstairs_fragrance
diff --git a/lovelace/15_3d_printer.yaml b/lovelace/15_3d_printer.yaml
new file mode 100644
index 0000000..0f17abb
--- /dev/null
+++ b/lovelace/15_3d_printer.yaml
@@ -0,0 +1,62 @@
+title: 3D Printer
+icon: mdi:printer-3d
+cards:
+ - type: picture-glance
+ id: 3d_printer_camera
+ title: 3D Printer Camera
+ entity: camera.3d_printer_camera
+ camera_image: camera.3d_printer_camera
+ show_info: false
+ tap_action:
+ action: more-info
+ entities:
+ - binary_sensor.motion_sensor_158d00016c2d0e
+
+ - type: vertical-stack
+ cards:
+ - type: horizontal-stack
+ cards:
+ - type: gauge
+ name: Percent 3D Print Complete
+ unit: "%"
+ entity: sensor.octoprint_job_percentage
+
+ - type: entities
+ title: Octoprint
+ show_header_toggle: false
+ entities:
+ - binary_sensor.octoprint_printing
+ - binary_sensor.octoprint_printing_error
+ - sensor.octoprint_actual_bed_temp
+ - sensor.octoprint_actual_tool0_temp
+ - sensor.octoprint_current_state
+ - sensor.octoprint_job_percentage
+ - sensor.octoprint_target_bed_temp
+ - sensor.octoprint_target_tool0_temp
+ - sensor.octoprint_time_elapsed
+ - sensor.octoprint_time_remaining
+
+ - type: entities
+ title: Percentage Complete
+ show_header_toggle: false
+ entities:
+ - input_boolean.twenty_five_percent
+ - input_boolean.fifty_percent
+ - input_boolean.seventy_five_percent
+ - input_boolean.hundred_percent
+
+ - type: entities
+ title: Print Times
+ show_header_toggle: false
+ entities:
+ - entity: sensor.time_elapsed
+ name: Elapsed
+ - entity: sensor.time_estimated
+ name: Estimated
+
+ - type: entities
+ title: 3D Printer
+ show_header_toggle: false
+ entities:
+ - switch.3d_printer
+ - input_boolean.power_off_when_complete
diff --git a/packages/3dprinting.yaml b/packages/3dprinting.yaml
index 85bf406..eaf745b 100644
--- a/packages/3dprinting.yaml
+++ b/packages/3dprinting.yaml
@@ -9,22 +9,91 @@ homeassistant:
automation.3d_print:
icon: mdi:printer
+input_boolean:
+ twenty_five_percent:
+ name: "25%"
+ initial: "off"
+ icon: mdi:radiobox-blank
+
+ fifty_percent:
+ name: "50%"
+ initial: "off"
+ icon: mdi:brightness-3
+
+ seventy_five_percent:
+ name: "75%"
+ initial: "off"
+ icon: mdi:brightness-2
+
+ hundred_percent:
+ name: "100%"
+ initial: "off"
+ icon: mdi:brightness-1
+
+ power_off_when_complete:
+ name: Auto Shutoff When Done
+ initial: "off"
+ icon: mdi:toggle-switch-off
#
-# Turn Off When the printer status changed from "Prnting" to anything.
+# Octoprint Camera URL in the format
+# still_image_url: "http://192.xxx.xxx.xxx/webcam/?action=snapshot"
+# mjpeg_url: "http://192.xxx.xxx.xxx/webcam/?action=stream"
#
+camera:
+ - platform: mjpeg
+ name: 3D Printer Camera
+ still_image_url: !secret octoprint_cam_snapshot
+ mjpeg_url: !secret octoprint_cam_stream
+
+#
+# A couple of template sensors to show the elapsed and estimated time in readable format
+# instead of # of seconds (default)
+#
+sensor:
+ - platform: template
+ sensors:
+ time_elapsed:
+ value_template: >
+ {%- macro secondsToReadableString(seconds) %}
+ {%- set map = {'week': (seconds / 604800) % 604800,
+ 'day': (seconds / 86400) % 7, 'hour': (seconds / 3600) % 24,
+ 'minute': (seconds / 60) % 60} -%}
+ {%- for item in map if map[item] | int > 0 -%}
+ {%- if loop.first %}{% elif loop.last %}, and {% else %}, {% endif -%}
+ {{- map[item]|int }} {{ item -}} {{- 's' if map[item]|int > 1 -}}
+ {%- endfor -%}
+ {% endmacro %}
+ {{ secondsToReadableString(states('sensor.octoprint_time_elapsed') |int) }}
+
+ - platform: template
+ sensors:
+ time_estimated:
+ value_template: >
+ {%- macro secondsToReadableString(seconds) %}
+ {%- set map = {'week': (seconds / 604800) % 604800,
+ 'day': (seconds / 86400) % 7, 'hour': (seconds / 3600) % 24,
+ 'minute': (seconds / 60) % 60 } -%}
+ {%- for item in map if map[item] | int > 0 -%}
+ {%- if loop.first %}{% elif loop.last %}, and {% else %}, {% endif -%}
+ {{- map[item]|int }} {{ item -}} {{- 's' if map[item]|int > 1 -}}
+ {%- endfor -%}
+ {% endmacro %}
+ {{ secondsToReadableString(states('sensor.octoprint_time_remaining') |int) }}
+
automation:
+ #
+ # Notify when the printer status changed from "Prnting" to anything.
+ # Use this later to determine if you want to turn off printer or not
+ #
- alias: "Octoprint 3D Print"
trigger:
platform: state
entity_id: "sensor.octoprint_current_state"
from: "Printing"
action:
- - delay: "00:00:59"
- - service: switch.turn_off
- entity_id: switch.3d_printer
- service: script.notify_me
data_template:
- message: "3D Printer Status Changed from 'Printing' to {{ trigger.to_state.state }}. Turned Off the Printer!"
+ message: "3D Printer Status Changed from 'Printing' to '{{ trigger.to_state.state }}'."
#
# Updates on the Printer Status
@@ -36,7 +105,7 @@ automation:
action:
- service: script.notify_me
data_template:
- message: "3D Printer Status is now {{ trigger.to_state.state }}"
+ message: "3D Printer Status changed from '{{ trigger.from_state.state }}' to '{{ trigger.to_state.state }}'."
#
# Notifies when the printer errors out
@@ -51,17 +120,31 @@ automation:
data_template:
message: "3D Printer Status changed to 'ERROR'. Please check the printer!"
+ #
+ # Updates appropriate input booleans based on percentage complete
+ #
+ - alias: "Update Percentage Booleans"
+ trigger:
+ platform: state
+ entity_id: sensor.octoprint_job_percentage
+ action:
+ - service_template: "input_boolean.turn_{{- 'on' if states('sensor.octoprint_job_percentage') | int > 25 else 'off' }}"
+ entity_id: input_boolean.twenty_five_percent
+ - service_template: "input_boolean.turn_{{- 'on' if states('sensor.octoprint_job_percentage') | int > 50 else 'off' }}"
+ entity_id: input_boolean.fifty_percent
+ - service_template: "input_boolean.turn_{{- 'on' if states('sensor.octoprint_job_percentage') | int > 75 else 'off' }}"
+ entity_id: input_boolean.seventy_five_percent
+ - service_template: "input_boolean.turn_{{- 'on' if states('sensor.octoprint_job_percentage') | int == 100 else 'off' }}"
+ entity_id: input_boolean.hundred_percent
+
#
# Provides update at frequent intervals - 25%, 50%, 75%, and 100%!
#
- alias: "Octoprint 3D Printer Progress Update"
trigger:
- platform: template
- value_template:
- "{{ states('sensor.octoprint_job_percentage') |int == 25 or
- states('sensor.octoprint_job_percentage') |int == 50 or
- states('sensor.octoprint_job_percentage') |int == 75 or
- states('sensor.octoprint_job_percentage') |int == 100 }}"
+ platform: state
+ entity_id: input_boolean.twenty_five_percent, input_boolean.fifty_percent, input_boolean.seventy_five_percent, input_boolean.hundred_percent
+ to: "on"
action:
- service: script.notify_me
data_template:
@@ -75,6 +158,37 @@ automation:
{{- map[item]|int }} {{ item -}} {{- 's' if map[item]|int > 1 -}}
{%- endfor -%}
{% endmacro %}
- 3D Printer - Print job is now {{ states('sensor.octoprint_job_percentage') |int }}% complete.
- Print Time: {{ secondsToReadableString(states('sensor.octoprint_time_elapsed') |int) }}
- Print Time Left: {{ secondsToReadableString(states('sensor.octoprint_time_remaining') |int) }}
+ 3D Printer job is now {{ trigger.to_state.attributes.friendly_name }} complete.
+ {% if trigger.entity_id != 'input_boolean.hundred_percent' %}
+ Time Spent: {{ secondsToReadableString(states('sensor.octoprint_time_elapsed') |int) }}.
+ Time Left: {{ secondsToReadableString(states('sensor.octoprint_time_remaining') |int) }}.
+ {% endif %}
+
+ #
+ # When the printing is complete (100%), it waits for 2 minutes and turns off the printer.
+ # It also resets all the input booleans, so that it starts fresh next time.
+ # Resetting input boleans is not necessary as they get updated automatically when
+ # octoprint job percentage value chaanges... but why not?
+ #
+ - alias: "Job Finished"
+ trigger:
+ platform: state
+ entity_id: input_boolean.hundred_percent
+ to: "on"
+ action:
+ - condition: template
+ value_template: "{{ states('input_boolean.power_off_when_complete') == 'on' }}"
+ - delay: "00:02:00"
+ - service: switch.turn_off
+ entity_id: switch.3d_printer
+ - service: script.notify_me
+ data_template:
+ message: "3D Printer is now switched off!"
+ - service_template: input_boolean.turn_off
+ entity_id: input_boolean.twenty_five_percent
+ - service_template: input_boolean.turn_off
+ entity_id: input_boolean.fifty_percent
+ - service_template: input_boolean.turn_off
+ entity_id: input_boolean.seventy_five_percent
+ - service_template: input_boolean.turn_off
+ entity_id: input_boolean.hundred_percent
diff --git a/ui-lovelace.yaml b/ui-lovelace.yaml
index 89187fa..6dfca4e 100644
--- a/ui-lovelace.yaml
+++ b/ui-lovelace.yaml
@@ -11,6 +11,7 @@ title: Kalavala's Home
views:
- !include lovelace/00_myhome_view.yaml
+ - !include lovelace/15_3d_printer.yaml
- !include lovelace/01_lights_view.yaml
- !include lovelace/02_climate_view.yaml
- !include lovelace/03_camera_view.yaml
diff --git a/zwcfg_0xd89c4f0c.xml b/zwcfg_0xd89c4f0c.xml
index d9e289a..8289558 100644
--- a/zwcfg_0xd89c4f0c.xml
+++ b/zwcfg_0xd89c4f0c.xml
@@ -163,7 +163,7 @@
-
+
@@ -273,7 +273,7 @@
-
+
@@ -289,9 +289,9 @@
-
+
-
+
@@ -575,11 +575,11 @@
-
-
-
+
+
+
-
+
@@ -749,7 +749,7 @@
-
+
@@ -758,8 +758,8 @@
-
-
+
+
@@ -805,7 +805,7 @@
-
+
@@ -835,7 +835,7 @@
-
+
@@ -1180,7 +1180,7 @@
-
+
@@ -1205,7 +1205,7 @@
-
+
@@ -1405,7 +1405,7 @@
-
+
@@ -1415,7 +1415,7 @@
-
+
@@ -1423,9 +1423,9 @@
-
+
-
+
@@ -1605,7 +1605,7 @@
-
+