Reading and writing saved data to/from a file. Why is this so hard?

I’m trying to create a system where there are different climate modes such as home, away, and sleep, and they set the temperatures in each room to preset values.

I figured what better way to store the values than a config file. I tried YAML and JSON, but couldn’t get either one working after hours of effort and trying to find examples online. The implementation in Home Assistant seems kind of hacky, you have to like load the file as a virtual sensor and siphon from the data through that, but I can’t get it working properly. It keeps messing up the formatting of the YAML automations every time they are saved and keeps changing the quotes in the JSON from double to single.

Is there any step-by-step tutorial for this somewhere? The official documentation seems to be lacking here. I looked into using a helper but there doesn’t seem to be one for an array or similar data type. Is there a way to just do it with Python directly from the automation? This is so simple in programming languages but so complicated in HA.

If you only have a list of options why not use an input_select helper for each room?

input_select:
  lounge_room_heating_mode:
    name: Lounge Room Heating Mode
    icon: mdi:sofa
    options:
      - Home
      - Away
      - Sleep

  master_bed_room_heating_mode:
    name: Master Bed Room Heating Mode
    icon: mdi:bed
    options:
      - Home
      - Away
      - Sleep

You can set the current option with a service in an automation or via the dashboard, and use a state condition and trigger in automations.

Is this what you mean? Matching an input select to a list of values? I think we have discussed the need for this a few times in the forums, but there is a way to do it: