- What is the problem?
When you use the Home Assistant for a long time and have more devices added, the Configuration.yaml file will become huge, this is the time to think about splitting the file. The first benefit is easy to see, the second is easy to find. But my own little use of this feature. Perhaps it is because the hobby gathers all of them into 1 for you, just use it normally.
- Resolved as follows:
We observe the following code:
homeassistant: latitude: 32.87336 longitude: 117.22743 elevation: 430 unit_system: metric time_zone: Asia/Ho_Chi_Minh name: Home customize: !include customize.yaml
The above lines are already known, now we should pay attention to the final code.
customize: !include customize.yamlInstead of leaving all the code of the customize class here, it will be long and hard to see, we can tell Hass to be: “Content of customize: you are bothered to view the customize.yaml file. We use the structure! Include tenfile.yaml. We create a new file named tenfile.yaml, and the content inside customize: then we leave it in this. Notice the file tenfile.yaml does not declare customize: at the beginning. Here is a specific example: We have configuration.yaml file with a paragraph like this:
sensor: - platform: time_date display_options: - 'time' - 'date'
We can separate the sensor class into a separate file with the structure. Then we create the sensor.yaml file with the content:
sensor: !include sensor.yaml
- platform: time_date
You see the file sensor.yaml we do not re-declare the sensor: okay. As you do the other classes in turn, we will shorten the configuration.yaml file
automation: !include automation.yaml zone: !include zone.yaml sensor: !include sensor.yaml switch: !include switch.yaml device_tracker: !include device_tracker.yaml