Skip to content

Commit

Permalink
Do not restart with empty timezone
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardtfn committed Nov 4, 2024
1 parent cbf05ae commit 69594a9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 19 deletions.
4 changes: 0 additions & 4 deletions esphome/nspanel_esphome_core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3151,14 +3151,10 @@ script:
ESP_LOGI("script.set_timezone", "Setting timezone: %s", timezone.c_str());
if (timezone != id(mui_timezone)) {
id(mui_timezone) = timezone;
if (timezone.empty())
arch_restart(); // Restart when timezone is set to blank so it uses the one from ESPHome compiller
size_t start = id(mui_timezone).find('<');
size_t end = id(mui_timezone).find('>');
if (start != std::string::npos && end != std::string::npos && end > start)
id(mui_timezone).replace(start, (end - start) + 1, "UTC");
if (id(mui_timezone).empty())
arch_restart(); // Restart when timezone is set to blank so it uses the one from ESPHome compiller
time_provider->set_timezone(id(mui_timezone).c_str());
time_provider->call_setup();
}
Expand Down
27 changes: 12 additions & 15 deletions nspanel_blueprint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8196,23 +8196,20 @@ action:
qrcode: !input qrcode_value
home_indoor_temp_icon: !input home_indoor_temp_icon
timezone: !input timezone
timezone_code: >
{{
timezone.split('(')[1]|replace(')', '')
if timezone.split('(') | count > 0
else timezone
}}

##### Timezone #####
- if: '{{ timezone is string and timezone | length > 1 }}'
then:
- variables:
timezone_code: >
{{
timezone.split('(')[1]|replace(')', '')
if timezone.split('(') | count > 0
else timezone
}}
- *delay_default
- service: 'esphome.{{ nspanel_name }}_set_string'
data:
component: "timezone"
val: '{{ timezone_code }}'
continue_on_error: true
- *delay_default
- service: 'esphome.{{ nspanel_name }}_set_string'
data:
component: "timezone"
val: '{{ timezone_code }}'
continue_on_error: true

##### Home page #####
- *delay_default
Expand Down

0 comments on commit 69594a9

Please sign in to comment.