48
48
icon : mdi:barcode
49
49
web_server :
50
50
sorting_group_id : sorting_group_printer_settings
51
- # on_value:
52
- # then:
51
+ on_value :
52
+ then :
53
+ - if :
54
+ condition :
55
+ lambda : |-
56
+ return !id(bambu_lan_access_code).state.empty() &&
57
+ !id(bambu_ip_address).state.empty() &&
58
+ !id(bambu_serial_number).state.empty();
59
+ then :
60
+ - logger.log : " Connecting to Bambu printer"
61
+ - mqtt.enable :
62
+ id : bambu_mqtt
63
+ else :
64
+ - logger.log : " Missing Bambu Credentials, skipping mqtt connect"
65
+ - mqtt.disable :
66
+ id : bambu_mqtt
67
+
53
68
# - script.execute: check_mqtt_creds #TODO: Enable once this is merged: https://github.com/esphome/esphome/pull/7716
54
69
# lambda: |-
55
70
# id(bambu_printer_status).topic = "device/" + x + "/report";
65
80
sorting_group_id : sorting_group_printer_settings
66
81
on_value :
67
82
then :
68
- lambda : |-
69
- id(bambu_mqtt).set_password(x.c_str());
70
- # - script.execute: check_mqtt_creds #TODO: Enable once this is merged: https://github.com/esphome/esphome/pull/7716
83
+ - lambda : |-
84
+ id(bambu_mqtt).set_password(x.c_str());
85
+ - if :
86
+ condition :
87
+ lambda : |-
88
+ return !id(bambu_lan_access_code).state.empty() &&
89
+ !id(bambu_ip_address).state.empty() &&
90
+ !id(bambu_serial_number).state.empty();
91
+ then :
92
+ - logger.log : " Connecting to Bambu printer"
93
+ - mqtt.enable :
94
+ id : bambu_mqtt
95
+ else :
96
+ - logger.log : " Missing Bambu Credentials, skipping mqtt connect"
97
+ - mqtt.disable :
98
+ id : bambu_mqtt
71
99
- platform : template
72
100
name : Printer IP Address
73
101
id : bambu_ip_address
@@ -80,9 +108,23 @@ text:
80
108
sorting_group_id : sorting_group_printer_settings
81
109
on_value :
82
110
then :
83
- lambda : |-
84
- id(bambu_mqtt).set_broker_address(x.c_str());
85
- # - script.execute: check_mqtt_creds #TODO: Enable once this is merged: https://github.com/esphome/esphome/pull/7716
111
+ - lambda : |-
112
+ id(bambu_mqtt).set_broker_address(x.c_str());
113
+ - if :
114
+ condition :
115
+ lambda : |-
116
+ return !id(bambu_lan_access_code).state.empty() &&
117
+ !id(bambu_ip_address).state.empty() &&
118
+ !id(bambu_serial_number).state.empty();
119
+ then :
120
+ - logger.log : " Connecting to Bambu printer"
121
+ - mqtt.enable :
122
+ id : bambu_mqtt
123
+ else :
124
+ - logger.log : " Missing Bambu Credentials, skipping mqtt connect"
125
+ - mqtt.disable :
126
+ id : bambu_mqtt
127
+
86
128
87
129
button :
88
130
- platform : restart
0 commit comments