Configuration, splitting yaml and where belongs what in which format

Hello,
I’ve again a little problem setting up my BBQ WLANThermo. There is a rep how to integrate in at homeassistant-wlanthermo and with that (and google) almost everythin works. I now struggle with the file wlanthermo_template.yaml, specially Line 588.
I didn’t use the folders as in gitHub, I’ve put all template stuff in template.yaml and adjusted it:


  - sensor:
      - name: wlanthermo_pitmaster_value_color
        unique_id: wlanthermo_pitmaster_value_color
        availability: >
          {{ not is_state('sensor.bbq_thermo','unavailable') }}
        state: >
          {{ state_attr('sensor.pitmaster_1_all', 'value_color') }}

  - number:
    - unique_id: wlanthermo_channel_1_max
      name: >
        #1 {{ state_attr('sensor.wlanthermo_channel_1_all', 'name') }} {% if is_state('input_boolean.wlanthermo_channel_1_timer','on') %}Target{% else %}Maximum{% endif %}
      state: "{{ state_attr('sensor.wlanthermo_channel_1_all', 'max') | int(0) }}"
      availability: >
        {{ not is_state('sensor.wlanthermo_channel_1_all', 'unavailable') }}
      set_value:
        service: mqtt.publish
        data_template:
          topic: WLanThermo/MINIV3/set/channels
          retain: true
          payload: >
            {"number":1,"max":{{ value }}}
      min: 0
      max: 300
      step: 1
      icon: mdi:thermometer-high

wlanthermo_pitmaster_value_color I can find at entities and works, but wlanthermo_channel_1_max is not listed anyware. Do I have to put them in input_number.yaml and what’s the correct syntax then? I just have one at the moment in there, this works (shows up) and looks like:

wlanthermo_pitmaster_temp:
  name: Pit Solltemperatur
  min: 0
  max: 250
  step: 1
  unit_of_measurement: °C
  icon: mdi:thermometer
  mode: box

But I’m not able to set values over MQTT. Maybe its also placed wrong and doesn’t belong to template.yaml?

  - select:
    - unique_id: wlanthermo_pitmaster_channel
      name: wlanthermo_pitmaster_channel
      icon: mdi:pound
      state: >
        #{{ state_attr('sensor.pitmaster_1_all', 'channel') }} {% if not is_state('sensor.wlanthermo_channel_'~(state_attr('sensor.pitmaster_1_all', 'channel'))~'_all','unavailable') and item.temp < 999 %}{{ state_attr('sensor.wlanthermo_channel_'~(state_attr('sensor.pitmaster_1_all', 'channel'))~'_all', 'name') }}{% else %}(unavailable){% endif %}
      availability: >
        {{ not is_state('sensor.wlanthermo_pitmaster_value', 'unavailable') }}
      select_option:
          service: mqtt.publish
          data_template:
            topic: WLanThermo/MINIV3/set/pitmaster
            retain: true
            payload: '{{ ''[{"id":0,"channel":''~(state_attr(''select.wlanthermo_pitmaster_channel'',''options'').index(option)+1)+'',"pid":''~state_attr(''sensor.pitmaster_1_all'', ''pid'')+'',"value":''~states(''number.wlanthermo_pitmaster_value'')+'',"set":''+states(''input_number.wlanthermo_pitmaster_temp'')+'',"typ":"''+states(''select.wlanthermo_pitmaster_mode'')+''"}]''}}'
      options: |-
        [
        {% if not is_state('sensor.bbq_thermo', 'unavailable') and (not is_state('sensor.bbq_thermo', 'unknown')) %}
        {% for item in state_attr('sensor.bbq_thermo', 'channel') %}
        {% if not is_state('sensor.wlanthermo_channel_'~item.number~'_all','unavailable') and item.temp < 999 %}
        '#{{ item.number }} {{ item.name }}',
        {% else %}
        '#{{ item.number }} (unavailable)',
        {% endif %}
        {% endfor %}
        {% else %}
        '1', '2', '3', '4', '5', '6', '7', '8'
        {% endif %}
        ]

Hope you can help me sorting the files out. :smiley:

In my setup, the top of configuration.yaml looks like this:

default_config:
automation: !include automations.yaml
automation manual: !include_dir_merge_list automations
binary_sensor: !include binary_sensors.yaml
climate: !include climate.yaml
group: !include groups.yaml
light: !include lights.yaml
mqtt:
  sensor: !include_dir_merge_list mqtt/sensors
  binary_sensor: !include_dir_merge_list mqtt/binary_sensors
  switch: !include_dir_merge_list mqtt/switches
proximity: !include proximity.yaml
rest: !include_dir_merge_list rest
schedule: !include_dir_merge_named schedules
sensor: !include_dir_merge_list sensors
script: !include scripts.yaml
shell_command: !include shell_commands.yaml
switch: !include switches.yaml
template: !include_dir_merge_list templates

This is all about “absorbing” the top-level headings. For example, one of my MQTT sensors would look like this, if it were put into the main file:

mqtt:
  sensor:
    - name: "Immersion switch overtemperature"
      unique_id: bba43721-1a8d-43eb-9088-cc32d4b7f1db
      state_topic: "shellies/shelly1pm-XXXXXX/overtemperature"

But from the file above, you can see that I have:

mqtt:
  sensor: !include_dir_merge_list mqtt/sensors

so that sensor is now in /config/mqtt/sensors/immersion.yaml (along with other related sensors in that file, and other non-immersion-related MQTT sensors in other files in the same folder) and looks like this in that file:

- name: "Immersion switch overtemperature"
  unique_id: bba43721-1a8d-43eb-9088-cc32d4b7f1db
  state_topic: "shellies/shelly1pm-XXXXXX/overtemperature"

When the !includes are processed by HA, it internally builds a configuration that is the same as if I had just put everything in the main file.

2 Likes

Hi, thank you for your answer. My configuration.yaml is not that big. :smiley:

script: !include scripts.yaml
scene: !include scenes.yaml
mqtt: !include mqtt.yaml
sensor: !include sensor.yaml
input_number: !include input_number.yaml
input_datetime: !include input_datetime.yaml
input_text: !include input_text.yaml

template: !include template.yaml
switch: !include switch.yaml

automation manual: !include_dir_merge_list automations/
automation ui: !include automations.yaml

But if I get you right, it should be:

template:
  - select:
    - unique_id: wlanthermo_pitmaster_channel
  - number:
    - unique_id: wlanthermo_channel_1_max

when parsed. I don’t understand why this is not working or do I need to use
template: !include_dir_merge_list templates and my template.yaml ind dir templates to get

  - number:
    - unique_id: wlanthermo_channel_1_min

working?

What you have should work according to the docs from a file structure point of view:

Is there anything in the logs relating to the setup of the number entity? The template in the name is waving red flags at me as a first place to look.

Juts to check: you are running a relatively recent version of HA aren’t you?

I had this file open more then once. :smiley: Gives all kind of examples, but never one with
- number:
From the logs it might be one similar to

2023-06-09 00:37:32.255 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140560981492368] Error handling message: template value should be a string for dictionary value @ data['sequence'][0]['data']. Got {'qos': '0', 'retain': False, 'topic': 'WLanThermo/MINIV3/set/pitmaster', 'payload_template': {'payload': '\'{{\'\'[{"id":0,"channel":\'\'~(state_attr(\'\'select.wlanthermo_pitmaster_channel\'\',\'\'options\'\').index(states(\'\'select.wlanthermo_pitmaster_channel\'\'))+1)+\'\',"pid":\'\'~state_attr(\'\'select.wlanthermo_pitmaster_profile\'\',\'\'options\'\').index(states(\'\'select.wlanthermo_pitmaster_profile\'\'))+\'\',"value":\'\'~states(\'\'number.wlanthermo_pitmaster_value\'\')+\'\',"se... (invalid_format) 

the name or uniq_id wlanthermo_channel_1_min I can’t find
Last update from OS and core was yesterday.

Home Assistant 2023.6.0
Supervisor 2023.06.1
Operating System 10.2
Frontend 20230607.0 - latest

Hoping someone can assist with this.
I have noticed that when I try to split up my configuration.yaml for intent scripts (voice) this does not work as I expect. Is this a known issue?
When I change configuration.yaml,
this works intent_script: !include custom_responses/responses.yaml
This does not work intent_script: !include_dir_merge_list custom_responses/
When I add conversation: to my configuration.yaml then I can have multiple *.yaml files located in the homeassistant/custom_sentences/en directory but I can’t seem to get this to work for intent_script: