Move "sensor data" from configuration.yaml to config/sensor>sensor.yaml

hi,
I’d like to make things cleaner so I’ve tried to move my “sensor data” from my configuration.yaml file to a file in a subdirectory config/sensor>sensor.yaml

in my configuration.yaml it was :
sensor:
  - platform: template
    sensors:
      weather_temperature:
        friendly_name: "Temperature Exterieure"
        unit_of_measurement: 'degrees'
        value_template: "{{ state_attr('weather.home', 'temperature') }}"
`
then i remove that and i add :  
sensor: !include_dir_merge_named sensor/

in my sensor.yaml file, i put :

- platform: template
  sensors:
    weather_temperature:
      friendly_name: "Temperature Exterieure"
      unit_of_measurement: 'degrees'
      value_template: "{{ state_attr('weather.home', 'temperature') }}"

when i check my config ==> configuration valid !

but in the UI i get a message :  entity not available 

remark : i've done the same cleaning for input_number , input_select ... and for them it works perfectly.
why it doesn't work for sensor ?

many thanks for your help
1 Like

If the first line of your sensor.yaml file is sensor.yaml then that’s invalid; remove it.

no it’s not the first line , it’s the file name.
thanks

Then you should fix your first post because that’s exactly how it appears there.

Annotation 2020-04-23 103625

ok. thanks

Do you put your sensor.yaml file in a directory called /config/sensor ?

If sensor.yaml is just in /config use this instead:

sensor: !include sensor.yaml
1 Like
yes i put sensor.yaml in the directoty /config/sensor 
and  "sensor: !include_dir_merge_named sensor/" in my configuration.yaml  : it doesn't work 

when i put sensor.yaml in /config 
and "sensor: !include sensor.yaml "in my configuration.yaml :  it works 

Try:

sensor: !include_dir_merge_list sensor
1 Like

FWIW, the documentation’s example, for !include_dir_merge_list, includes a trailing slash:

Example:

automation: !include_dir_merge_list automation/
1 Like

Ya, slash doesn’t seem to matter, but if there’s only 1 yaml file in the folder, merge_named doesn’t work while merge_list does.

I’m trying to do this as well and now all of my sensors are unavailable. I wanted to organize my sensors as the list is expanding.

In my config, I have the following: sensor: !include_dir_merge_list sensor/
then I have the following structure config/sensor/default_sensors.yaml with all of my sensors. I have updated to Supervisor 220 and Home Assistant 0.109.2 recently.

I have checked my configuration and it says valid but I don’t think Home Assistant is seeing my sensor yaml anymore. I tried changing it back to the way I had it before and still no dice.

#Sensors
                        
smartweather:
  - platform: smartweather
    station_id: 
    api_key: 
##################################################  
#Wyze
binary_sensor:
  - platform: wyzesense
    device: auto
     "/dev/hidraw0"

        
wyzeapi:
  - platform: wyzeapi
    username: 
    password: 

#logger:
#     default: warning
#      logs:
#        custom_components.wyzeapi: debug
light:
  - platform: wyzeapi
    username: 
    password:  
    
switch:
  - platform: wyzeapi
    username: 
    password: 

#wyzeapi:
#username: !secret wyze_user
#password: !secret 
##################################################  
tuya:
  - platform: tuya
    username: 
    password: 
    country_code: 1
##################################################

weather:
  - platform: darksky
    api_key: 
###################################################

darksky:
  - platform: darksky
    api_key: 
    forecast:
      - 0
    hourly_forecast:
      - 0
      - 1
    monitored_conditions:
      - summary
      - icon
      - temperature
####################################################