2021-05-10 16:29:41 ERROR (MainThread) [homeassistant.helpers.check_config] Unexpected error validating config
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/check_config.py", line 155, in async_check_ha_config_file
await config_validator.async_validate_config( # type: ignore
File "/usr/src/homeassistant/homeassistant/components/script/config.py", line 115, in async_validate_config
cfg = await _try_async_validate_config_item(hass, object_id, cfg, config)
File "/usr/src/homeassistant/homeassistant/components/script/config.py", line 93, in _try_async_validate_config_item
raw_config = dict(config)
TypeError: 'NoneType' object is not iterable
For this script:
boot_cast_device_and_set_volume_without_bleeps:
description: Ensures a Google Home device is activated with a pre-set volume and won't emit any sounds while doing so.
sequence:
- choose:
#
# When the device is in OFF state, we first mute the player in order to hide the startup sound and then wait until the idle is booted.
#
- conditions:
- condition: state
entity_id: media_player.$PLAYER
state: off
sequence:
- service: media_player.volume_mute
target:
entity_id: media_player.$PLAYER
data:
is_volume_muted: true
- service: media_player.turn_on
target:
entity_id: media_player.$PLAYER
- wait_template: '{{ is_state(''media_player.$PLAYER'', ''idle'') }}'
#
# Now that the device is in 'idle' state, we are going to:
# - Mute the device
# - Play media (silent MP3)
# - Wait for the device to start playing
# - Change the audio level (since the device is playing, won't show the BLOOP sound)
# - Unmute the device
#
- conditions:
- condition: state
entity_id: media_player.$PLAYER
state: idle
sequence:
- service: media_player.volume_mute
target:
entity_id: media_player.$PLAYER
data:
is_volume_muted: true
- service: media_player.play_media
target:
entity_id: media_player.$PLAYER
data:
media_content_type: audio
media_content_id: media-source://media_source/local/1-minute-of-silence.mp3
- wait_template: '{{ is_state(''media_player.$PLAYER'', ''playing'') }}'
- service: media_player.volume_set
target:
entity_id: media_player.$PLAYER
data:
volume_level: $VOLUME_LEVEL
- service: media_player.volume_mute
target:
entity_id: media_player.$PLAYER
data:
is_volume_muted: false
- service: tts.google_translate_say
data:
entity_id: media_player.$PLAYER
message: 'This is a test!'
default: []
mode: single
It seems to be properly formatted, but i canât spot the error.
This isnât something wrong with the code per se, it is simply a notice, that a state that youâre working with, is not ready. Possibly because you restarted or the sensor isnât available for other reasons.
For example, this brings up a âNoneObjectâ (=no object), that canât be iterated. How could it, if there is no object present.
Because at that point, where an object is needed, there isnât one. That can be for example, because something is not reachable, not working (battery empty) or whatever.
In your case it seems, something is not reporting anything, thatâs why there is âno objectâ, (=NoneObject) and therefor no iteration possible.
What makes you think, it is this specific script? In the error log there is no connection made, so it could be anywhereâŚ
Thanx! In the end it was indeed something with indentation, and the configuration now validates. Would this be the right change for the template condition?
This is the modified script:
ready_cast_with_set_volume:
description: Ensures a Google Home device is activated with a pre-set volume
sequence:
- choose:
- conditions:
- condition: template
value_template: '{{ is_state(''media_player.'' ~ player, ''off'') }}'
sequence:
- service: media_player.volume_mute
target:
entity_id: 'media_player.{{ player }}'
data:
is_volume_muted: true
- service: media_player.turn_on
target:
entity_id: 'media_player.{{ player }}'
- wait_template: '{{ is_state(''media_player.'' ~ player, ''idle'') }}'
- conditions:
- condition: template
value_template: '{{ is_state(''media_player.'' ~ player, ''idle'') }}'
sequence:
- service: media_player.volume_mute
target:
entity_id: 'media_player.{{ player }}'
data:
is_volume_muted: true
- service: media_player.play_media
target:
entity_id: 'media_player.{{ player }}'
data:
media_content_type: audio
media_content_id: 'media-source://media_source/local/1-minute-of-silence.mp3'
- wait_template: '{{ is_state(''media_player.'' ~ player, ''playing'') }}'
- service: media_player.volume_set
target:
entity_id: 'media_player.{{ player }}'
data:
volume_level: '{{ volume_level }}'
- service: media_player.volume_mute
target:
entity_id: 'media_player.{{ player }}'
data:
is_volume_muted: false
- service: tts.google_translate_say
data:
entity_id: 'media_player.{{ player }}'
message: This is an alert!
default: []
mode: single