Skip to content

Commit 5db82be

Browse files
committed
lint
1 parent e3977a9 commit 5db82be

22 files changed

+1761
-1764
lines changed

firmware/conf.d/automation.yaml

Lines changed: 325 additions & 326 deletions
Large diffs are not rendered by default.

firmware/conf.d/bambu_printer.yaml

Lines changed: 115 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -1,125 +1,124 @@
11
---
22
select:
3-
#TODO: printer model is currently unused, but will be needed for setting AMS type
4-
- platform: template
5-
name: Printer Model
6-
id: bambu_model
7-
state_topic:
8-
options:
9-
- "A1Mini"
10-
- "A1"
11-
- "P1P/P1S"
12-
- "X1C/X1E"
13-
optimistic: true
14-
restore_value: true
15-
icon: mdi:printer-3d
16-
web_server:
17-
sorting_group_id: sorting_group_printer_settings
3+
#TODO: printer model is currently unused, but will be needed for setting AMS type
4+
- platform: template
5+
name: Printer Model
6+
id: bambu_model
7+
state_topic:
8+
options:
9+
- "A1Mini"
10+
- "A1"
11+
- "P1P/P1S"
12+
- "X1C/X1E"
13+
optimistic: true
14+
restore_value: true
15+
icon: mdi:printer-3d
16+
web_server:
17+
sorting_group_id: sorting_group_printer_settings
1818

1919
text:
20-
- platform: template
21-
name: Printer Serial Number
22-
id: bambu_serial_number
23-
state_topic:
24-
optimistic: true
25-
mode: text
26-
restore_value: true
27-
icon: mdi:barcode
28-
web_server:
29-
sorting_group_id: sorting_group_printer_settings
30-
on_value:
31-
then:
32-
- if:
33-
condition:
34-
lambda: |-
35-
return !id(bambu_lan_access_code).state.empty() &&
36-
!id(bambu_ip_address).state.empty() &&
37-
!id(bambu_serial_number).state.empty();
38-
then:
39-
- logger.log:
40-
level: info
41-
format: "Connecting to Bambu printer"
42-
- mqtt.enable:
43-
id: bambu_mqtt
44-
else:
45-
- logger.log:
46-
level: info
47-
format: "Missing Bambu Credentials, skipping mqtt connect"
48-
- mqtt.disable:
49-
id: bambu_mqtt
50-
51-
# - script.execute: check_mqtt_creds #TODO: Enable once this is merged: https://github.com/esphome/esphome/pull/7716
52-
# lambda: |-
53-
# id(bambu_printer_status).topic = "device/" + x + "/report";
54-
- platform: template
55-
name: Printer Lan Access Code
56-
id: bambu_lan_access_code
57-
state_topic:
58-
optimistic: true
59-
mode: password
60-
restore_value: true
61-
icon: mdi:lock
62-
web_server:
63-
sorting_group_id: sorting_group_printer_settings
64-
on_value:
65-
then:
66-
- lambda: |-
67-
id(bambu_mqtt).set_password(x.c_str());
68-
- if:
69-
condition:
70-
lambda: |-
71-
return !id(bambu_lan_access_code).state.empty() &&
72-
!id(bambu_ip_address).state.empty() &&
73-
!id(bambu_serial_number).state.empty();
74-
then:
75-
- logger.log:
76-
level: info
77-
format: "Connecting to Bambu printer"
78-
- mqtt.enable:
79-
id: bambu_mqtt
80-
else:
81-
- logger.log:
82-
level: info
83-
format: "Missing Bambu Credentials, skipping mqtt connect"
84-
- mqtt.disable:
85-
id: bambu_mqtt
86-
- platform: template
87-
name: Printer IP Address
88-
id: bambu_ip_address
89-
state_topic:
90-
optimistic: true
91-
mode: text
92-
restore_value: true
93-
icon: mdi:ip
94-
web_server:
95-
sorting_group_id: sorting_group_printer_settings
96-
on_value:
97-
then:
98-
- lambda: |-
99-
id(bambu_mqtt).set_broker_address(x.c_str());
100-
- if:
101-
condition:
102-
lambda: |-
103-
return !id(bambu_lan_access_code).state.empty() &&
104-
!id(bambu_ip_address).state.empty() &&
105-
!id(bambu_serial_number).state.empty();
106-
then:
107-
- logger.log:
108-
level: info
109-
format: "Connecting to Bambu printer"
110-
- mqtt.enable:
111-
id: bambu_mqtt
112-
else:
113-
- logger.log: "Missing Bambu Credentials, skipping mqtt connect"
114-
- mqtt.disable:
115-
id: bambu_mqtt
20+
- platform: template
21+
name: Printer Serial Number
22+
id: bambu_serial_number
23+
state_topic:
24+
optimistic: true
25+
mode: text
26+
restore_value: true
27+
icon: mdi:barcode
28+
web_server:
29+
sorting_group_id: sorting_group_printer_settings
30+
on_value:
31+
then:
32+
- if:
33+
condition:
34+
lambda: |-
35+
return !id(bambu_lan_access_code).state.empty() &&
36+
!id(bambu_ip_address).state.empty() &&
37+
!id(bambu_serial_number).state.empty();
38+
then:
39+
- logger.log:
40+
level: info
41+
format: "Connecting to Bambu printer"
42+
- mqtt.enable:
43+
id: bambu_mqtt
44+
else:
45+
- logger.log:
46+
level: info
47+
format: "Missing Bambu Credentials, skipping mqtt connect"
48+
- mqtt.disable:
49+
id: bambu_mqtt
50+
# - script.execute: check_mqtt_creds #TODO: Enable once this is merged: https://github.com/esphome/esphome/pull/7716
51+
# lambda: |-
52+
# id(bambu_printer_status).topic = "device/" + x + "/report";
53+
- platform: template
54+
name: Printer Lan Access Code
55+
id: bambu_lan_access_code
56+
state_topic:
57+
optimistic: true
58+
mode: password
59+
restore_value: true
60+
icon: mdi:lock
61+
web_server:
62+
sorting_group_id: sorting_group_printer_settings
63+
on_value:
64+
then:
65+
- lambda: |-
66+
id(bambu_mqtt).set_password(x.c_str());
67+
- if:
68+
condition:
69+
lambda: |-
70+
return !id(bambu_lan_access_code).state.empty() &&
71+
!id(bambu_ip_address).state.empty() &&
72+
!id(bambu_serial_number).state.empty();
73+
then:
74+
- logger.log:
75+
level: info
76+
format: "Connecting to Bambu printer"
77+
- mqtt.enable:
78+
id: bambu_mqtt
79+
else:
80+
- logger.log:
81+
level: info
82+
format: "Missing Bambu Credentials, skipping mqtt connect"
83+
- mqtt.disable:
84+
id: bambu_mqtt
85+
- platform: template
86+
name: Printer IP Address
87+
id: bambu_ip_address
88+
state_topic:
89+
optimistic: true
90+
mode: text
91+
restore_value: true
92+
icon: mdi:ip
93+
web_server:
94+
sorting_group_id: sorting_group_printer_settings
95+
on_value:
96+
then:
97+
- lambda: |-
98+
id(bambu_mqtt).set_broker_address(x.c_str());
99+
- if:
100+
condition:
101+
lambda: |-
102+
return !id(bambu_lan_access_code).state.empty() &&
103+
!id(bambu_ip_address).state.empty() &&
104+
!id(bambu_serial_number).state.empty();
105+
then:
106+
- logger.log:
107+
level: info
108+
format: "Connecting to Bambu printer"
109+
- mqtt.enable:
110+
id: bambu_mqtt
111+
else:
112+
- logger.log: "Missing Bambu Credentials, skipping mqtt connect"
113+
- mqtt.disable:
114+
id: bambu_mqtt
116115

117116
button:
118-
- platform: restart
119-
name: "Restart OpenSpool"
120-
id: restart_openspool
121-
state_topic:
122-
entity_category: diagnostic
117+
- platform: restart
118+
name: "Restart OpenSpool"
119+
id: restart_openspool
120+
state_topic:
121+
entity_category: diagnostic
123122

124123
#TODO: Show the current state of the printer
125124

firmware/conf.d/button.yaml

Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,64 @@
11
---
22
binary_sensor:
3-
- platform: gpio
4-
name: "Button"
5-
id: physical_button
6-
state_topic:
7-
internal: true
8-
pin:
9-
number: 0
10-
mode: INPUT_PULLUP
11-
inverted: true
12-
on_press:
13-
then:
14-
- script.execute:
15-
id: set_led_red
16-
led_number: -1
17-
- globals.set:
18-
id: button_press_duration
19-
value: "0"
20-
- script.execute: start_timer
21-
on_release:
22-
then:
23-
- script.execute:
24-
id: set_led_white
25-
led_number: -1
26-
- script.stop: timer_script
27-
- if:
28-
condition:
29-
lambda: "return id(button_press_duration) >= 10;"
30-
then:
31-
- logger.log: "Erasing WiFi credentials and restarting..."
32-
- button.press: factory_reset_openspool
33-
else:
34-
- logger.log: "Button released before 10 seconds, not performing factory reset."
35-
globals:
36-
- id: my_counter
37-
type: int
38-
initial_value: "0"
39-
- id: button_press_duration
40-
type: int
41-
initial_value: "0"
42-
script:
43-
- id: timer_script
3+
- platform: gpio
4+
name: "Button"
5+
id: physical_button
6+
state_topic:
7+
internal: true
8+
pin:
9+
number: 0
10+
mode: INPUT_PULLUP
11+
inverted: true
12+
on_press:
4413
then:
45-
- while:
46-
condition:
47-
binary_sensor.is_on: physical_button
48-
then:
49-
- globals.set:
50-
id: button_press_duration
51-
value: !lambda "return id(button_press_duration) + 1;"
52-
- delay: 1s
53-
- id: start_timer
14+
- script.execute:
15+
id: set_led_red
16+
led_number: -1
17+
- globals.set:
18+
id: button_press_duration
19+
value: "0"
20+
- script.execute: start_timer
21+
on_release:
5422
then:
23+
- script.execute:
24+
id: set_led_white
25+
led_number: -1
26+
- script.stop: timer_script
27+
- if:
28+
condition:
29+
lambda: "return id(button_press_duration) >= 10;"
30+
then:
31+
- logger.log: "Erasing WiFi credentials and restarting..."
32+
- button.press: factory_reset_openspool
33+
else:
34+
- logger.log: "Button released before 10 seconds, not performing factory reset."
35+
globals:
36+
- id: my_counter
37+
type: int
38+
initial_value: "0"
39+
- id: button_press_duration
40+
type: int
41+
initial_value: "0"
42+
script:
43+
- id: timer_script
44+
then:
45+
- while:
46+
condition:
47+
binary_sensor.is_on: physical_button
48+
then:
5549
- globals.set:
5650
id: button_press_duration
57-
value: "0"
58-
- script.execute: timer_script
51+
value: !lambda "return id(button_press_duration) + 1;"
52+
- delay: 1s
53+
- id: start_timer
54+
then:
55+
- globals.set:
56+
id: button_press_duration
57+
value: "0"
58+
- script.execute: timer_script
5959
button:
60-
- platform: factory_reset
61-
name: "Factory Reset"
62-
id: factory_reset_openspool
63-
state_topic:
64-
internal: true
60+
- platform: factory_reset
61+
name: "Factory Reset"
62+
id: factory_reset_openspool
63+
state_topic:
64+
internal: true

0 commit comments

Comments
 (0)