chunkysteveo / OpenEPaperLink-HA-Weatherman

Wetherman EPaper display using OpenEPaperLink and the HA Integration
37 stars 4 forks source link

Error when changing to 24h #17

Closed MrGlad8 closed 8 months ago

MrGlad8 commented 9 months ago

Ok so I followed closely your guide on how to change to 24h. But after changing the part in the automation I get this error when trying to run the automation: Error: Error rendering data template: TypeError: %d format: a real number is required, not str Any ideas whats wrong? :)

chunkysteveo commented 9 months ago

Can you upload your weatherman sensor yaml and your automation yaml for us to look at - it's difficult to guess.

This is occuring as your time coming into the automation is probably still a string, and it's expecting a decimal - the %d is d for decimal.

MrGlad8 commented 9 months ago

Sure, here is the template: https://dpaste.org/DDMA4 And here is the automation: https://dpaste.org/GP0hS

Are the variables in the code right? Aren't those suppose to be added in the automation as its own building block like before the action?

chunkysteveo commented 8 months ago

Just tested your config and it works fine. The only time I got that error was if I changed my times to "not 24h" versions. If I use your time format in your Weatherman Data Tag sensor (%H) it works perfect. When changing the time format, you do need to refresh your template entities (https://YOUT_HA_INSTALL/developer-tools/yaml) at the bottom, and also either wait 15 mins, or change the /15 in your weatherman sensor to /1 to make it update every minute, not 15, and then wait 1 minute and try below -

Can you send me what you get if you find your Weatherman Data Tag entity in the State page (https://YOUT_HA_INSTALL/developer-tools/state). You should get something like below. Check that your wm_time_0, 1,2,3 are showing as numbers: image

MrGlad8 commented 8 months ago

I'm sorry I'm probably doing something wrong. But I cant get it to work. But if I leave the code as it was before in the automation: {{ state_attr('sensor.weatherman_data_tag','wm_time_0') | string | upper }} It actually works.. I see 24 hour on my display.. no errors.. so I dont know hehe.

Here is the state of the weatherman entity:

moon_phase: moon-waning-crescent sun_next_rising: 6:48 AM sun_next_setting: 5:57 PM temperature_unit: °C wind_speed_unit: km/h precipitation_unit: mm pressure_unit: hPa wm_cond_now: cloudy wm_temp_now: 4 wm_wind_speed_now: 12 wm_wind_dir_now: 59 wm_dew_point_now: -0.3 wm_humidity_now: 75 wm_cloud_coverage_now: 99.8 wm_pressure_now: 1031.3 wm_cond_0: cloudy wm_temp_0: 4 wm_precipitation_0: 0 wm_wind_speed_0: 10 wm_wind_dir_0: 54 wm_time_0: 17 wm_cond_1: cloudy wm_temp_1: 3 wm_precipitation_1: 0 wm_wind_speed_1: 9 wm_wind_dir_1: 53 wm_time_1: 18 wm_cond_2: cloudy wm_temp_2: 3 wm_precipitation_2: 0 wm_wind_speed_2: 9 wm_wind_dir_2: 57 wm_time_2: 19 wm_cond_3: cloudy wm_temp_3: 2 wm_precipitation_3: 0 wm_wind_speed_3: 9 wm_wind_dir_3: 68 wm_time_3: 20 wm_cond_4: sunny wm_temp_4: 6 wm_precipitation_4: 0 wm_temp_4_low: -2 wm_wind_speed_4: 6 wm_wind_dir_4: 302 wm_time_4: Tor wm_cond_5: partly-cloudy wm_temp_5: 8 wm_precipitation_5: 0 wm_temp_5_low: -3 wm_wind_speed_5: 10 wm_wind_dir_5: 77 wm_time_5: Fre wm_cond_6: partly-cloudy wm_temp_6: 4 wm_precipitation_6: 0 wm_temp_6_low: -1 wm_wind_speed_6: 16 wm_wind_dir_6: 76 wm_time_6: Lör wm_cond_7: cloudy wm_temp_7: 4 wm_precipitation_7: 0 wm_temp_7_low: 0 wm_wind_speed_7: 21 wm_wind_dir_7: 71 wm_time_7: Sön wm_cond_8: cloudy wm_temp_8: 5 wm_temp_8_low: -1 wm_precipitation_8: 0 wm_wind_speed_8: 20 wm_wind_dir_8: 57 wm_time_8: Mån friendly_name: Weatherman Data Tag

I see yours ends with _forecast but I guess you made your own and not like the one in the guide?

chunkysteveo commented 8 months ago

The _forecast is just my sensor. I guess if yours works without the formatting, it's a win!!

Can we close this off? And your other issue?

chunkysteveo commented 8 months ago

OK, as found in another issue - we need to update the automation script for the times, for time_0,time_1,time_2,time_3 to the following (replacing wm_time_0 with 0,1,2,3 etc based on the time attribute you are printing):

{{ '%0.2d' | format(state_attr('sensor.weatherman_data_tag','wm_time_0') | int) | string | upper }}

Note the inclusion of the | int in the line of code, which is missing in your automation, and causes an error.