Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

indicator_ha showing one hour less #48

Open
jardous opened this issue Feb 23, 2024 · 8 comments
Open

indicator_ha showing one hour less #48

jardous opened this issue Feb 23, 2024 · 8 comments
Labels
bug Something isn't working

Comments

@jardous
Copy link

jardous commented Feb 23, 2024

indicator_hr is showing one hour less than it should

Time Auto Update: ON

timezone Europe/Berlin

two possible culprits:

  1. daylight saving time is not taken into account
  2. ntp is not working properly - I see some errors in the log:
E (9522) esp-tls-mbedtls: mbedtls_ssl_setup returned -0x7F00
E (9523) esp-tls: create_ssl_handle failed
E (9524) esp-tls: Failed to open new connection
E (9534) city: Connection failed...
I (10536) city: Get time zone...
E (10583) esp-tls-mbedtls: mbedtls_ssl_setup returned -0x7F00
E (10584) esp-tls: create_ssl_handle failed
E (10584) esp-tls: Failed to open new connection
E (10595) city: Connection failed...
I (11596) city: Get time zone...
E (11642) esp-tls-mbedtls: mbedtls_ssl_setup returned -0x7F00
E (11643) esp-tls: create_ssl_handle failed
E (11643) esp-tls: Failed to open new connection
@Love4yzp Love4yzp added the bug Something isn't working label Feb 28, 2024
@metlinux
Copy link

metlinux commented Jun 4, 2024

I hade the same issue, and it seems to be caused by a part of the code in indicator_city.c
Actually there is no issue with ssl but with the zonestr

To be precise it occurs in "static void __indicator_http_task(void *p_arg)"

I adjusted:

        if(  net_flag && ip_flag && !time_zone_flag) {
            ESP_LOGI(TAG, "Get time zone...");
            err =  __time_zone_get(__g_city_model.ip); 
            if( err == 0) {
                char zone_str[32];
                float zone = __g_city_model.local_utc_offset / 3600.0;

                if( zone >= 0) {
                    snprintf(zone_str, sizeof(zone_str) - 1, "UTC-%.1f", zone);
                } else {
                    snprintf(zone_str, sizeof(zone_str) - 1, "UTC+%.1f", 0 - zone);
                }
                indicator_time_net_zone_set( zone_str );

                time_zone_flag = true;
            }
        }

into

         if(  net_flag && ip_flag && !time_zone_flag) {
            ESP_LOGI(TAG, "Get time zone...");
            char zone_str[32];
            snprintf(zone_str, sizeof(zone_str) - 1, "UTC-2:00");
            indicator_time_net_zone_set( zone_str );
            time_zone_flag = true;
       }

I agree it is somewhat radical, and limits my zone to UTC-2:00, so please if you use this adjust this to your own zone
But it works till it gets fixed. With this error you have, it will continue to loop through this procedure which seems a waste of resources.

If others know of a better fix, please share

@the-confused-genius
Copy link

Hey @metlinux

The actual issue is that the code fetches the UTC based on you IP address using an API.
This UTC is then not properly formatted in the code, which causes the time error.

Yes you can either hard code the UTC or change the snprintf line so that the UTC is formatted properly as expected by dependent code

You can check this #25 issue as it is a similar one and I have provided the fix there.

@yupyvovarov
Copy link

I have a similar issue
зображення
but only with indicator_ha, indicator_basis uses identical code and does not produce this error. I do not understand why and how to fix it.

@the-confused-genius
Copy link

@yupyvovarov It seems to be connection issue with your wifi ?

Is It able to connect with your wifi ?
The internal chip used here is esp32 which has issue connecting with 5 GHz wifi, so is you wifi having 2.4 Ghz ?

Have you used the same code provided in the release build ?
and have you tried flashing different (previous) release builds ?

@yupyvovarov
Copy link

@the-confused-genius No it's not. The WiFi connection is OK. It can connect to the internet, retrieve location, and send metrics to HA, but do not set a time zone. As I mentioned, the basic example firmware works perfectly, the ha example - doesn't.
The Indicator HA update release firmware works as expected, but failed when I tried to build it by myself.

@metlinux
Copy link

I have a similar issue зображення but only with indicator_ha, indicator_basis uses identical code and does not produce this error. I do not understand why and how to fix it.

I also just had it with indicator_ha. Do try the workaround that I mentioned above....

@yupyvovarov
Copy link

@metlinux Your fix will probably work. But I am curious why the same indicator_city code works for indicator_basic. What is the difference?

@lordmortis
Copy link
Contributor

lordmortis commented Aug 17, 2024

that mbedtls_ssl_setup error implies that there isn't enough memory. If you check out components/mbedtls/mbedtls/include/mbedtls/ssl.h, line 112 (of a checked out project) MBEDTLS_ERR_SSL_ALLOC_FAILED is mapped to -0x7F00.

What's a bit interesting is I added a log for getting the current heap free (ESP_LOGI(TAG, "Heap Free: %i", esp_get_free_heap_size());) just before the get request call (line 440 in examples/indicator_ha/main/model/indicator_city.c) and it showed there was 5 meg free (I (8594) city: Heap Free: 5173796), so it seems odd, unless i've got the wrong format specifier there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants