krash
(Harry)
February 1, 2021, 9:44pm
41
Apologies, for some reason I wrote the above post wrong, give me a sec, ill correct it.
Everything i say about script, should be sensor.
To create two sensor you will need to use the code twice:
sensors:
octoprint_1_time_elapsed_format:
...
octoprint_1_time_remaining_format:
...
octoprint_2_time_elapsed_format:
...
octoprint_2_time_remaining_format:
...
Inside there, you will need to substitute any instance of my names with each of your printers’
In the code states.sensor.octoprint_time_remaining.state
you should change the middle part according to your printers’ names for each sensor.
Hobby4life
(Hobby4Life)
February 3, 2021, 10:30pm
42
Thanks!, I got it working
Only the remaining time script did not work.
Instead I took the elapsed time script and used that.
krash
(Harry)
February 4, 2021, 9:59am
43
If you wan to try and fix the remaining time, paste your code and entities, maybe we can spot some error and fix it.
Hobby4life
(Hobby4Life)
February 4, 2021, 6:00pm
44
This is what I have running as a script for 1 printer.
Running in sensors.yaml
- platform: template
sensors:
octoprint_ender3_links_time_elapsed_format:
friendly_name: 'Printing Time Elapsed'
value_template: >-
{% set etime = states.sensor.ender3_links_time_elapsed.state | int %}
{% set seconds = etime % 60 %}
{% set minutes = ((etime % 3600) / 60) | int %}
{% set hours = ((etime % 86400) / 3600) | int %}
{% set days = (etime / 86400) | int %}
{%- if days > 0 -%}
{%- if days == 1 -%}
1 day
{%- else -%}
{{ days }} days
{%- endif -%}
{{ ', ' }}
{%- endif -%}
{%- if hours > 0 -%}
{%- if hours == 1 -%}
1 hour
{%- else -%}
{{ hours }} hours
{%- endif -%}
{{ ', ' }}
{%- endif -%}
{%- if minutes > 0 -%}
{%- if minutes == 1 -%}
1 minute
{%- else -%}
{{ minutes }} minutes
{%- endif -%}
{%- endif -%}
octoprint_ender3_links_time_remaining_format:
friendly_name: 'Printing Time Remaining'
value_template: >-
{% set etime = states.sensor.ender3_links_time_remaining.state | int %}
{% set seconds = etime % 60 %}
{% set minutes = ((etime % 3600) / 60) | int %}
{% set hours = ((etime % 86400) / 3600) | int %}
{% set days = (etime / 86400) | int %}
{%- if days > 0 -%}
{%- if days == 1 -%}
1 day
{%- else -%}
{{ days }} days
{%- endif -%}
{{ ', ' }}
{%- endif -%}
{%- if hours > 0 -%}
{%- if hours == 1 -%}
1 hour
{%- else -%}
{{ hours }} hours
{%- endif -%}
{{ ', ' }}
{%- endif -%}
{%- if minutes > 0 -%}
{%- if minutes == 1 -%}
1 minute
{%- else -%}
{{ minutes }} minutes
{%- endif -%}
{%- endif -%}
This is not working
- platform: template
sensors:
octoprint_ender3_links_time_elapsed_format:
friendly_name: 'Printing Time Elapsed'
value_template: >-
{% set etime = states.sensor.octoprint_ender3_links_time_elapsed.state | int %}
{% set seconds = etime % 60 %}
{% set minutes = ((etime % 3600) / 60) | int %}
{% set hours = ((etime % 86400) / 3600) | int %}
{% set days = (etime / 86400) | int %}
{%- if days > 0 -%}
{%- if days == 1 -%}
1 day
{%- else -%}
{{ days }} days
{%- endif -%}
{{ ', ' }}
{%- endif -%}
{%- if hours > 0 -%}
{%- if hours == 1 -%}
1 hour
{%- else -%}
{{ hours }} hours
{%- endif -%}
{{ ', ' }}
{%- endif -%}
{%- if minutes > 0 -%}
{%- if minutes == 1 -%}
1 minute
{%- else -%}
{{ minutes }} minutes
{%- endif -%}
{%- endif -%}
octoprint_ender3_links_time_remaining_format:
friendly_name: 'Printing Time Remaining'
value_template: >-
{% set rtime = states.sensor.octoprint_ender3_links_time_remaining.state | int %}
{% set seconds = rtime % 60 %}
{% set minutes = ((rtime % 3600) / 60) | int %}
{% set hours = ((rtime % 86400) / 3600) | int %}
{% set days = (rtime / 86400) | int %}
{%- if days > 0 -%}
{%- if days == 1 -%}
1 day
{%- else -%}
{{ days }} days
{%- endif -%}
{{ ', ' }}
{%- endif -%}
{%- if hours > 0 -%}
{%- if hours == 1 -%}
1 hour
{%- else -%}
{{ hours }} hours
{%- endif -%}
{{ ', ' }}
{%- endif -%}
{%- if minutes > 0 -%}
krash
(Harry)
February 4, 2021, 6:21pm
45
Ok, from what see at first glance
You dont need to enter this part of the code twice.
- platform: template
sensors:
You just enter it once and then declare the names of the different sensors you make, kind of like this:
- platform: template
sensors:
sensor1:
sensor2:
sensor3:
The second thing i notice, is that the two blocks of code seems idential to me.
You need to give them a different name, and in the states.sensor.ender3_links_time_elapsed.state
part, you need to enter the name of your second printer (assuming ender3_links is the name of the first one)
Sennevds
(Sennevds)
February 5, 2021, 7:25am
46
Really nice setup. I’ve copied a part of your setup. Last week this lovelace card was released for octoprint and it looks really nice dangreco/threedy: Home Assistant card for 3D printer status and management. (github.com)
krash
(Harry)
February 5, 2021, 7:27am
47
ah yes, saw it on reddit, it’s very nice
Botap
(Botap)
February 9, 2021, 9:52am
49
Hi, that card looks indeed very nice but I am unable to find the file threedy-card.js on Gitihub. Can you either post a link or provide me with a copy of the card?
Sennevds
(Sennevds)
February 9, 2021, 10:05am
50
Botap
(Botap)
February 9, 2021, 5:25pm
51
Thanks a lot for the link. I found it and got it to work. It looks really nice
Vansify
(Tibo G.)
February 17, 2021, 1:43am
52
Would you be willing to share your code? Specifically how you can get that much control over your printer through home assistant. Looks awesome!
1 Like
legolas08
(mauro)
February 28, 2021, 8:49am
53
shell_command:
octoprint_nozzle_temperature: "curl -s http://youripoctoprint/api/printer/command -d '{\"command\":\"M109 S{{ states('input_number.nozzle_temperature') }}\"}' -H 'Content-Type: application/json' -H 'X-Api-Key: your api key'"
input_number:
nozzle_temperature:
unit_of_measurement: '°C'
mode: box
min: 0
max: 250
name: Temperatura Nozzle
script:
octoprint_nozzle_temperature:
sequence:
service: shell_command.octoprint_nozzle_temperature
here is an example of how I make the commands, in the octoprint api page you will find all the references you need
3 Likes
Grrr
(Graham Slack)
May 25, 2021, 9:53am
54
more shell commands in this thread:
Hello everyone!
I wonder if someone could help me creating a rest switch for my Octoprint server to connect to the printer. I’ve found the documentation here: http://docs.octoprint.org/en/master/api/connection.html
Could not get it to work, here is my config:
- platform: rest
name: "Conectar Octoprint"
resource: 'http://192.168.1.69/api/connection'
body_on: '{"command":"connect"}'
body_off: '{"command":"disconnect"}'
is_on_template: "{% if is_state('sensor.octoprint_current_state', …
1 Like
There’s a great plugin for OctoPrint which communicates with Home Assistant via MQTT.
It updates faster than the native HA integration and also exposes a switch for connecting/disconnecting which I found way easier to use than making a shell command.
3 Likes
Am i wrong or in the first post there are no config for the power consumption graphs and camera.octoprint?
krash
(Harry)
August 25, 2021, 9:14am
58
You will find them within the next to last code section near the end of the post.
- entities:
- entity: sensor.d_link_plug_current_power_w
name: Current Power
- entity: sensor.d_link_plug_total_consumption
name: Total Power
color: gray
y_axis: secondary
hours_to_show: 24
color_thresholds:
- value: 50
color: green
- value: 100
color: orange
- value: 150
color: red
line_width: 3
show:
labels: true
legend: false
labels_secondary: true
and
- aspect_ratio: 50%
camera_image: camera.octoprint
entity: camera.octoprint
image: 'http://octopi.local/webcam/?action=snapshot'
show_name: false
show_state: false
type: picture-entity
GlennHA
(Glenn)
September 12, 2021, 4:46am
59
Do you use Add-ons in OctoPrint to get info into HA?
Or are you getting the other sensors into HA a different way?
I just made a filament scale and have the Filament Scale add-on working to display the info in OctoPrint, however, with the OctoPrint integration in HA I don’t get any of the add-on info.
Will the MQTT in OctoPrint send out the info for the add-ons?
wasyl00
September 12, 2021, 6:25am
60
I made my filament scale using ESPHome so it does not depend on Octoprint. Its better IMO as it works even when the Octoprint is switched off
1 Like