Hi all,
I hope to be able to get some help in here. I use the met.no nowcast integration available on HACS. GitHub - toringer/home-assistant-metnowcast: Met.no Nowcast component for Home Assistant
When using the new weather get_forecasts I get a response back that contains datetime objects and I am having trouble figuring out how to handle them in templates.
To test I have set up a service test in the developer tools:
service: weather.get_forecasts
target:
entity_id: weather.met_no_nowcast_neshamn
data:
type: hourly
response_variable: wf
This returns the response (truncated below) which is exactly what I would like:
weather.met_no_nowcast_neshamn:
forecast:
- temperature: 10.8
precipitation: 0
relative_humidity: 68
wind_bearing: 153.4
wind_speed: 8.28
wind_speed_of_gust: 6
datetime: "2024-04-09T08:45:00+00:00"
condition: cloudy
- temperature: null
precipitation: 0
datetime: "2024-04-09T08:50:00+00:00"
- temperature: null
precipitation: 0
datetime: "2024-04-09T08:55:00+00:00"
- temperature: null
precipitation: 0
datetime: "2024-04-09T09:00:00+00:00"
However when I run the same service from a template I get a response that looks like this containing datetime objects and not fully stringified json:
forecast: >-
[{'temperature': 10.7, 'precipitation': 0.0, 'relative_humidity': 66.2,
'wind_bearing': 156.4, 'wind_speed': 6.48, 'wind_speed_of_gust': 5.3,
'datetime': datetime.datetime(2024, 4, 9, 9, 35,
tzinfo=datetime.timezone.utc), 'condition': 'cloudy'}, {'temperature': None,
'precipitation': 0.0, 'datetime': datetime.datetime(2024, 4, 9, 9, 40,
tzinfo=datetime.timezone.utc)}, {'temperature': None, 'precipitation': 0.0,
'datetime': datetime.datetime(2024, 4, 9, 9, 45,
tzinfo=datetime.timezone.utc)}, {'temperature': None, 'precipitation': 0.0,
'datetime': datetime.datetime(2024, 4, 9, 9, 50,
tzinfo=datetime.timezone.utc)}, {'temperature': None, 'precipitation': 0.0,
'datetime': datetime.datetime(2024, 4, 9, 9, 55,
tzinfo=datetime.timezone.utc)}, {'temperature': None, 'precipitation': 0.0,
Any ideas how I can convert this attribute to something more manageable? At the moment I cannot call from_json because the datetime objects are there.
Somehow the developer tools was able to correctly convert the response to something sane.