Include input_datetime

Back again - still messing with configurations - and have spent a good hour on this - i am just not getting the YAML construct.

This is a snip of my confugration.yaml. All includes are working except for the ‘input_datetime’ line…

group:  !include groups.yaml
switch:  !include_dir_list switch/
sensor:  !include_dir_list sensor/
binary_sensor:  !include_dir_list binary_sensor/
automation:  !include_dir_list automations/
zone:  !include_dir_list zones/
input_datetime:  !include_dir_list timings/

my ‘timings folder’ contains two files - dark start / dark end. Contents below :-1:

[file1]
  dark_mode_start:
    has_date: false
    has_time: true
    initial: '23:30:00'

[file2]
  dark_mode_end:
    has_date: false
    has_time: true
    initial: '07:30:00'

and finally the error when i check the config. I know i am overengineering this splitting the config - but i have to understand how it works to enable me to make the right decisions later.

Invalid config for [input_datetime]: 
expected dictionary for dictionary value @ data['input_datetime']. 
Got 
[
OrderedDict([('dark_mode_start', None), ('has_date', False), ('has_time', True), ('initial', '23:30:00')]), 
OrderedDict([('dark_mode_end', None), ('has_date', False), ('has_time', True), ('initial', '07:00:00')])
]. (See ?, line ?).

Tried so many combinations of indents, hyphens, so over to you guys.

Thanks all

You need to use include_dir_merge_named instead of include_dir_list in this case.

1 Like

Worked a treat with no other changes. Thanks - really apprecaite the quick response. But how would i know this? It was the only thing i hadn’t tried. When do i use

include_dir_list

over

include_dir_merge_list

Thanks

It can be a bit confusing / overwhelming at first (it too me a while to get my head wrapped around it), but it depends on what you’re including and what you’re putting in the files. Just look at the examples on that page. After you study them a bit the light bulb should go on. :slightly_smiling_face:

BTW, I tend to use packages. Much more flexible and allows you to group things more logically.

A few people are advocating packages now - i will most probably switch over to them once i understand how it all hangs together.

If the things being split out if left in the configuration.yaml are all divided up by a preceding hyphen (-) for each entry then you use the “_list” variant. If they are divided up as each item without a hyphen you use the “_named” variant.

examples of “_list” items are automation, sensor & switch

examples of “_named” items are group, script & shell_command

I use a combination of !includes & packages because it makes the most logical sense to me and allows me to use packages in the way they were originally intended - by allowing you to group different domains that are used in a “system” into a single file. Like if you have an “alarm system” that uses automations, scripts, booleans, switches, lights, etc you can group all of those things within the package so you don’t need to open multiple files to modify them. And still helps you to break up your config into more manageable bite sized pieces.

If there are things that aren’t part of a larger logical “system” then I just use different includes.

And for one-off things (like life360, zwave, zigbee, mqtt, etc) that only require a single instance in the config then I just leave all of those in the main configuration.yaml file.

1 Like