2024.6: Dipping our toes in the world of AI using LLMs 🤖

I upgraded from 2024.5.5 to 2024.6.1 two days ago, and I’m noticing this very concerning issue.

Emphasis on Failed to serialize to JSON.

2024-06-11 13:35:24.824 ERROR (SyncWorker_17) [homeassistant.helpers.json] Failed to serialize to JSON: /home/homeassistant/.homeassistant/.storage/core.config_entries. Bad data at $.data.entries[105].data.scan_interval=1 day, 0:00:00(<class 'datetime.timedelta'>, $.data.entries[106].data.scan_interval=1 day, 0:00:00(<class 'datetime.timedelta'>, $.data.entries[107].data.scan_interval=1 day, 0:00:00(<class 'datetime.timedelta'>, $.data.entries[108].data.scan_interval=1 day, 0:00:00(<class 'datetime.timedelta'>, $.data.entries[109].data.scan_interval=1 day, 0:00:00(<class 'datetime.timedelta'>, $.data.entries[110].data.scan_interval=1 day, 0:00:00(<class 'datetime.timedelta'>, $.data.entries[111].data.scan_interval=1 day, 0:00:00(<class 'datetime.timedelta'>, $.data.entries[112].data.scan_interval=1 day, 0:00:00(<class 'datetime.timedelta'>, $.data.entries[113].data.scan_interval=1 day, 0:00:00(<class 'datetime.timedelta'>
2024-06-11 13:35:24.825 ERROR (MainThread) [homeassistant.helpers.storage] Error writing config for core.config_entries: Failed to serialize to JSON: /home/homeassistant/.homeassistant/.storage/core.config_entries. Bad data at $.data.entries[105].data.scan_interval=1 day, 0:00:00(<class 'datetime.timedelta'>, $.data.entries[106].data.scan_interval=1 day, 0:00:00(<class 'datetime.timedelta'>, $.data.entries[107].data.scan_interval=1 day, 0:00:00(<class 'datetime.timedelta'>, $.data.entries[108].data.scan_interval=1 day, 0:00:00(<class 'datetime.timedelta'>, $.data.entries[109].data.scan_interval=1 day, 0:00:00(<class 'datetime.timedelta'>, $.data.entries[110].data.scan_interval=1 day, 0:00:00(<class 'datetime.timedelta'>, $.data.entries[111].data.scan_interval=1 day, 0:00:00(<class 'datetime.timedelta'>, $.data.entries[112].data.scan_interval=1 day, 0:00:00(<class 'datetime.timedelta'>, $.data.entries[113].data.scan_interval=1 day, 0:00:00(<class 'datetime.timedelta'>

I’m struggling to find hard evidence for this, but I think it’s related to the file integration migration to the UI. My reason is purely that I have 9 of these sensors and there are 9 errors per log entry – every time.

Here’s one of my sensor configs:

    - platform: file
      file_path: /home/homeassistant/.homeassistant/downloads/latest_dam_levels.csv
      name: Steenbras Lower Dam Level
      unit_of_measurement: "%"
      value_template: "{{ '%0.2f'| format(value.split(',')[7] | round(2)) }}"
      scan_interval: 86400

I asked on this core issue what the default scan interval is, but I haven’t received an answer yet. Is it 1 second? The UI doesn’t provide a way to check the full configuration (cannot see the template or scan interval).

Has anybody else noticed at least the same error?

In case someone asks: I haven’t edited my .storage files manually, no.

I will do things when I have time*:

  1. Inspect the file integration code.
  2. Enable debug logging.

*My time is extremely limited at the moment.

Yep I know, during the stream they talked about it being more than a mere selector, with conditions or ways to change it via services (like an Unsplash integration) and asked for feedback on this very topic.

My guess (I havent been able to confirm otherwise) is you’re best bet would be to disable the auto ‘polling for updates’ on the individual entries’s system settings

and add an automation with your requirements.

I openend an issue on the lack of the path/template in the current config, because of which we now need to delete the entry and create a new one if changes are needed… I now see you responded there too…(sorry for missing that)

other than that, you can find the specifics in the core.config_entries:

      {
        "data": {
          "value_template": "{% if value is not none %}\n  {% if value|length < 255 %} {{value}}\n  {% else %} Truncated: {{value|truncate(240,True, '')}}\n  {% endif %}\n{% endif %}\n",
          "platform": "sensor",
          "file_path": "/config/logging/filed/filed_notifications.txt",
          "name": "Filed notifications"
        },
        "disabled_by": null,
        "domain": "file",
        "entry_id": "c4ac56c0190d80309c023f4a98320c05",
        "minor_version": 1,
        "options": {},
        "pref_disable_new_entities": false,
        "pref_disable_polling": false,
        "source": "import",
        "title": "Filed notifications",
        "unique_id": null,
        "version": 1
      },

but yes, that is no way this should have passed. Hope the dev (who already joined in the issue) can fix that

In what way is Extended OpenAI Conversation Integration different from the OpenAI integration demonstrated in the HA 2024.6 release party ?

That’s the thing… I had no such entries.

I now upgraded to 2024.6.2 and all these file sensor are now gone.

I suspect what happened now is that I’ve removed the YAML and the import failed (sensors existed in memory but not on disk), causing the error I posted previously, and now after a restart it’s gone.

arghh, thats too bad if you had a lot…

suppose you didnt ‘comment’ the yaml, but really deleted it…? a backup will quickly return the yaml though

phew, this made me quickly check… still all good.

so yes, find that previous yaml, do a quick restart, import them and be done with it

Thanks for the sympathy!

Luckily, it’s all in GitHub and in this case it was all commented out for now – until I could confirm the migration happened correctly. I reverted to YAML for now – and the error is back.

I’ve logged the issue: Unable to migrate file integration sensors from YAML to UI · Issue #119404 · home-assistant/core (github.com).

so does it work if you take out the scan_interval?

not saying it would be a fix, but it would help you migrate, and use the automation

Ah, no, I fully reverted the YAML, but I will try what you say tomorrow. It could be a specific field. My gut said it was maybe the template field, but perhaps it’s the scan interval.

That looks like a scan interval timedelta object was imported into config flow data, and since timedelta objects cannot be serialized to JSON its failing to save the config entry.

Please open an issue (if there isn’t one already) for whichever integration is importing that, and point to my comment above, as it should help track down the source of the issue.

Ai , so much talk about ai. But what do you DO with it?

Thanks, Nick!

The link to the issue have been posted a few posts up. I’ll tag you directly on the GitHub issue now.

1 Like

Check the demos shown in the Home Assistent 2024.6 Release Party video on YouTube:

Can you turn on a light please…
How far is …

Still not convinced. Looking for a ‘killer use case’

Was there a breaking change to Google Cast or mDNS in this release? All of my Google Cast devices went unavailable… I was able to get them all back with adding the IP list string in the UI but they had all been working fine till this update for many releases.

Amazing update!

Has anyone tried it with GPT3.5-Turbo?

I have tested OpenAI Conversation with gpt-4o and it works perfectly! The only thing is that each interaction usually costs approximately 0.10 euros.
When trying with gpt-3.5-turbo (approximately 0.1 euros/interaction) it does not work so well for me. If I ask him “How is the kitchen light?”, he turns it on and tells me that it is on (I just wanted to know the status!)
I speak to him in Spanish.
I have not been able to test it with the Google API because it is not available here in Spain.

Thank you!

1 Like

Hi Dani,

same Probleme here. GTP-3.5 Turbo don’t work very well. GPT 4o is much better.

Brilliant, just what I was looking for!

could this be related: Group state of device_tracker is 'on/off' and not 'home/away' after restart HA · Issue #119411 · home-assistant/core · GitHub

not sure if this is confirmed already, but given your description for groups with states on/off instead of home/not_home, please have a look?

My ESP32Box was previously using the HA Voice / Whisper etc and I tried swapping it to Google Generative AI. It no longer wants to add items to my shopping list which working fine before.

Anyone else have this issue?