Trying to extract 2pm temp from climacell_hourly... no results in sensor, no error in log

Hi there i want to use the 2pm temp from climacell_hourly.

I have this in my sensors.yaml

#Max Temp um 14 Uhr
- platform: template
  sensors:
    max_temp_today:
      friendly_name: "Max. Temp. heute 14 Uhr"
      unit_of_measurement: '°C'
      value_template: "{{ state_attr('weather.climacell_hourly', '14:00:00') | float(0) }}"

but obviously I did something wrong, but I have right now no idea what that might be and how I could find out. the logs did not show anything related to “climacell”

However I just realized, that I would need to not monitor just the forecast but to pull that temp forecast each day before 2 pm. Otherwise it will pull the next days temp after 2 pm and then change my depending calculations, so therefore I would have to store it before 2 pm to be able to keep providing it to my today calculation. so I would need to store it. so maybe Ill do it 6 am and store it for the day. but then I think I need a timed trigger to fetch the climacell value and store it in my sensor for this day. other option would be to operate till 2 pm on forecast and after 2 pm on real outdoor temp.

Thanks
Manne

The actual forecast is an indexed array and you need to filter that entries by the desired time (14:00h).

{{ state_attr('weather.climacell_hourly','forecast') | selectattr('datetime','eq',as_timestamp(today_at("14:00"),0) | timestamp_utc(0)) | map(attribute='temperature') | join | float(0) }}
1 Like

awesome, thanks,

follow up qustion: how do I know that the stuff i want to pull is an indexed array, where do I see these information or how do i get them? i dont want to bother the board every time i build a sensor and fail to judge the entity the right way.

Entwicklerwerkzeuge → Zustände

1 Like

and i now have in the yamle file

#Max Temp um 14 Uhr
- platform: template
  sensors:
    max_temp_today:
      friendly_name: "Max. Temp. heute 14 Uhr"
      unit_of_measurement: '°C'
      value_template: {{ state_attr('weather.climacell_hourly','forecast') | selectattr('datetime','eq',as_timestamp(today_at("14:00"),0) | timestamp_utc(0)) | map(attribute='temperature') | join | float(0) }}

but get this from the check config

Error loading /config/configuration.yaml: while parsing a flow mapping
in “/config/sensors.yaml”, line 83, column 24
expected ‘,’ or ‘}’, but got ‘’
in “/config/sensors.yaml”, line 83, column 74

My bad, i mixed quotes and double quotes. Try:

value_template: "{{ state_attr('weather.climacell_hourly','forecast') | selectattr('datetime','eq',as_timestamp(today_at('14:00'),0) | timestamp_utc(0)) | map(attribute='temperature') | join | float(0) }}"
1 Like

ah, i see, i tried the double quotes but did not realize that mine where botched up by the one around 1400… sorry, my fault, should have been obvious.

with the corrected quotes its reporting the right temp now. :smiley:

thanks again.

1 Like

I discovered that my sensor did fall to “0” on 15:31, as I thought, I would have to trigger it on a specific time to only update it once a day. Otherwise, on the next update after 2 pm the forecast is not for same day anymore and therefore gives a zero as return since the code wants day to be today and time to be 2pm.

then i have the other issue, that it must be persistent through reboot, since I dont want to kill my shading with a reboot after the trigger did run, but i cant trigger on ha start since if I reboot after 3 pm, the shading would be broken as well.

so I first moved it from sensors.yaml to template.yaml and added a timed trigger for 6 am, as i need it for shading calculations, so there is no need to fetch it earlier, there is no shading done before 6 am, dont know if climacell updates the hourly during the day.

code now looks like this. (got inspiration from this thread: click

#Max Temp at 14 Uhr
  - trigger:
      - platform: time_pattern
        # This will update every night at 1 am
        hours: "6"
        minutes: "0"
        # this will update on start
        # - platform: homeassistant
        # event: start
    action:
      - service: input_number.set_value
        data:
          entity_id: input_number.cover_max_temp_today
          value: "{{ state_attr('weather.climacell_hourly','forecast') | selectattr('datetime','eq',as_timestamp(today_at('14:00'),0) | timestamp_utc(0)) | map(attribute='temperature') | join | float(0) }}"

I first created the input helper via UI.

Config test says all green, now lets see if it works :slight_smile: tomorrow ill know.

edit: I already discovered it not working. I had it in the wrong place and petro did point that out to me, so i fixed it, it basically belongs into the automations.yaml, but its a wise choice to use the UI to create the entry and safe it. then go back and edit in yaml and just paste the “value:” stuff and let the UI handle the rest

Cheers Manne

1 Like

deleted post,