Expected string or bytes-like object. How to debug?

After moving to my new house I restarted HA again but get a lot of issues, mainly caused by the recorder not running. First error is:

Fatal error while loading config: expected string or bytes-like object

This is very unclear, no hint as to where this comes from, like what line or file is causing this.

As some components did not move to the new house I did edit my config file to reflect the new situation. Also I updated to the latest version of HA Core (0.118.1) but have the issues with 0.115, 0.116 and 0.117 as well.

I am running HA core on a RPI3 running debian. Using MariaDB instead of SQLight, which was running fine for years before.

Running hass --script check_config results in this error:

Testing configuration at /home/homeassistant/.homeassistant
Fatal error while loading config: expected string or bytes-like object
Failed config
  General Errors: 
    - expected string or bytes-like object

Successful config (partial)

The first error in my log file is telling me that recorder is not setup

2020-11-20 09:50:58 ERROR (MainThread) [homeassistant.bootstrap] Error setting up integration recorder - received exception
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/setup.py", line 64, in async_setup_component
    return await task  # type: ignore
  File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/setup.py", line 158, in _async_setup_component
    await async_process_deps_reqs(hass, config, integration)
  File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/setup.py", line 343, in async_process_deps_reqs
    await requirements.async_get_integration_with_requirements(
  File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/requirements.py", line 74, in async_get_integration_with_requirements
    await async_process_requirements(
  File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/requirements.py", line 121, in async_process_requirements
    if pkg_util.is_installed(req):
  File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/util/package.py", line 54, in is_installed
    return version(req.project_name) in req
  File "/srv/homeassistant/lib/python3.8/site-packages/pkg_resources/__init__.py", line 3078, in __contains__
    return self.specifier.contains(item, prereleases=True)
  File "/srv/homeassistant/lib/python3.8/site-packages/pkg_resources/_vendor/packaging/specifiers.py", line 703, in contains
    item = parse(item)
  File "/srv/homeassistant/lib/python3.8/site-packages/pkg_resources/_vendor/packaging/version.py", line 31, in parse
    return Version(version)
  File "/srv/homeassistant/lib/python3.8/site-packages/pkg_resources/_vendor/packaging/version.py", line 200, in __init__
    match = self._regex.search(version)
TypeError: expected string or bytes-like object

My configuration file:

homeassistant:
  name: Home Assisant
  latitude: !secret lat_home
  longitude: !secret long_home
  elevation: 21
  unit_system: metric
  time_zone: Europe/Amsterdam
  #customize: !include customize.yaml
  auth_providers:
    - type: trusted_networks
      trusted_networks:
        - 192.168.1.0/24

system_health:

person:
  
# Enables the frontend
frontend:

lovelace:
  mode: yaml
  dashboards:
    lovelace-energie:
      mode: yaml
      filename: lovelace-energy.yaml
      title: Energie
      show_in_sidebar: true
    lovelace-system:
      mode: yaml
      filename:  lovelace-system.yaml
      title: System
      show_in_sidebar: true

# Enables configuration UI
config:

recorder:
  purge_keep_days: 7
  db_url: !secret mydburl
  exclude:
    entities:
      - sensor.date
      - sensor.time
      - sensor.last_boot
      - automation.circadian_time_transition

 
# states: ciritcal, fatal, error, warning, warn, info, debug, notset
logger:
  default: warn

updater:
  include_used_components: true

zone: !include zone.yaml

# Allows you to issue voice commands from the frontend in enabled browsers
#conversation:

history:
  exclude:
    entities:
      - sensor.time
      - sensor.date

logbook:

map:

sun:

evohome:
  username: !secret mail
  password: !secret hony

input_boolean: !include inpboolean.yaml

input_select:
  paul_status_dropdown:
    name: Paul
    options:
      - Home
      - Just Arrived
      - Just Left
      - Away
      - Extended Away
    initial: Home
  noreen_status_dropdown:
    name: Noreen
    options:
      - Home
      - Just Arrived
      - Just Left
      - Away
      - Extended Away
    initial: Home
  paul_status_location:
    name: Paul_home_location
    options:
      - beganegrond
      - eerste
      - tweede
  noreen_status_location:
    name: Noreen_home_location
    options:
      - beganegrond
      - eerste
      - tweede

# Text to speech
#tts:
#  - platform: google_translate
#    service_name: google_say
#    language: 'nl'

notify:
  - name: mypushbullet
    platform: pushbullet
    api_key: !secret pbapi

deconz:
  host: 192.168.1.70

mobile_app:

media_player: !include media.yaml

switch: !include_dir_merge_list switch/

binary_sensor: !include binsensor.yaml

sensor: !include_dir_merge_list sensors/

group: !include_dir_merge_named group/

automation: !include_dir_merge_list auto/

script: !include_dir_merge_named scripts/

I am stuck as the error message is not clear what is going on. Where is this error coming from? How to debug this?

Have you figured out what happened? I’m facing similar issue, which in my case took down the HACS.

Unfortunately I have no solution yet. I suspect some data left behind in the storage section for devices/sensors that are not there anymore. Still searching…

Same error message here, but no clue as to what the problem is or how to debug it.

I initially noticed this when all my binary_sensors stopped working. I assumed it was related (and perhaps it is) but I was able to fix the binary_sensors by removing my v2.db. I’m still seeing that error message, but as far as I can tell everything else in HA is working OK

I don’t know how significant this is… But I verified that I was still seeing this error on 2021.1.3 today, then it went away after upgrading to 2021.1.4. Maybe it was not so much the specific version as the fact that the system went through an upgrade because I reverted to 2021.1.3 and don’t see it there either.

good that updating worked for you. Unfortunately it did not help in my case.

Should be fixed here

I get the same after upgrading to 2021.12.3

Unexpected error validating config
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/check_config.py", line 161, in async_check_ha_config_file
    await config_validator.async_validate_config(  # type: ignore
  File "/usr/src/homeassistant/homeassistant/components/automation/config.py", line 129, in async_validate_config
    await asyncio.gather(
  File "/usr/src/homeassistant/homeassistant/components/automation/config.py", line 106, in _try_async_validate_config_item
    config = await async_validate_config_item(hass, config, full_config)
  File "/usr/src/homeassistant/homeassistant/components/automation/config.py", line 74, in async_validate_config_item
    config[CONF_TRIGGER] = await async_validate_trigger_config(
  File "/usr/src/homeassistant/homeassistant/helpers/trigger.py", line 50, in async_validate_trigger_config
    conf = await platform.async_validate_trigger_config(hass, conf)
  File "/usr/src/homeassistant/homeassistant/components/homeassistant/trigger.py", line 15, in async_validate_trigger_config
    return await getattr(platform, "async_validate_trigger_config")(hass, config)
  File "/usr/src/homeassistant/homeassistant/components/homeassistant/triggers/state.py", line 71, in async_validate_trigger_config
    config = TRIGGER_STATE_SCHEMA(config)
  File "/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py", line 272, in __call__
    return self._compiled([], data)
  File "/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py", line 594, in validate_dict
    return base_validate(path, iteritems(data), out)
  File "/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py", line 386, in validate_mapping
    cval = cvalue(key_path, value)
  File "/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py", line 817, in validate_callable
    return schema(data)
  File "/usr/src/homeassistant/homeassistant/helpers/config_validation.py", line 293, in entity_ids_or_uuids
    return _entity_ids(value, True)
  File "/usr/src/homeassistant/homeassistant/helpers/config_validation.py", line 283, in _entity_ids
    return [validator(ent_id) for ent_id in value]
  File "/usr/src/homeassistant/homeassistant/helpers/config_validation.py", line 283, in <listcomp>
    return [validator(ent_id) for ent_id in value]
  File "/usr/src/homeassistant/homeassistant/helpers/config_validation.py", line 271, in entity_id_or_uuid
    return fake_uuid4_hex(value)
  File "/usr/src/homeassistant/homeassistant/helpers/config_validation.py", line 711, in fake_uuid4_hex
    if not _FAKE_UUID_4_HEX.match(value):
TypeError: expected string or bytes-like object```