Creating configuration files

Hello, I configure HA, I encountered a problem, I create an additional file, they do not work, here is my config.yaml

 homeassistant:
   name: Home
   latitude: !secret
   longitude: !secret
   elevation: 10
   unit_system: metric
   time_zone: Europe/Moscow  
   customize: !include customize.yaml    
   
   packages:
     datetime: !include packages/datetime.yaml
     weather: !include packages/weather.yaml
     devpi: !include packages/dev_pi.yaml

 frontend:
 config:

 http:
   api_password: !secret
   ssl_certificate: !secret
   ssl_key: !secret

 updater:
 discovery:
 conversation:
 history:
 logbook: !include logbook.yaml
 logger:
   default: warning
   logs:
     homeassistant.components.mqtt: debug

 sun:

 tts:
   platform: google


 mqtt:
   broker: 127.0.0.1
   port: 1883
   client_id: home-assistant-1
   keepalive: 60
   username: !secret
   password: !secret
 #  protocol: 3.1
   
   
 zone: !include zones.yaml
 group: !include groups.yaml
 automation: !include automations.yaml
 device_tracker: !include device_tracker.yaml
 sensor: !include sensors.yaml
 input_boolean: !include input_boolean.yaml

Files sensor and input_boolean, do not work, in that section I added them?
Sensors.yaml

 - platform: mqtt
     state_topic: 'home/sensor1'
     name: 'Temperature'
     unit_of_measurement: '°C'
     value_template: '{{ value_json.temperature }}'
        
 - platform: mqtt
    state_topic: 'home/sensor1'
    name: 'Humidity'
    unit_of_measurement: '%'
    value_template: '{{ value_json.humidity }}'  

input_boolean.yaml

alarmweekday: 
  name: 
  initial: on 
  icon: mdi:calendar

The name should be sensors.yaml (lowercase S) and the mqtt platform needs spaces removing so that state, name, unit and value line up with the ‘p’ in platform and the dash needs to be against the edge of the page.

- platform: mqtt
  state_topic: 'home/sensor1'
  name: 'Temperature'
  unit_of_measurement: '°C'
  value_template: '{{ value_json.temperature }}'
        
- platform: mqtt
  state_topic: 'home/sensor1'
  name: 'Humidity'
  unit_of_measurement: '%'
  value_template: '{{ value_json.humidity }}'

The input_boolean looks OK :slight_smile:

2 Likes

It does not work, the file was renamed to sensor.yaml

2017-07-05 22:25:59 ERROR (Thread-1) [homeassistant.util.yaml] Unable to read file /home/homeassistant/.homeassistant/sensor.yaml: ‘utf-8’ codec can’t decode byte 0xb0 in position 104: invalid start byte
2017-07-05 22:25:59 ERROR (MainThread) [homeassistant.bootstrap] Error loading /home/homeassistant/.homeassistant/configuration.yaml: ‘utf-8’ codec can’t decode byte 0xb0 in position 104: invalid start byte

sensor.yaml

- platform: mqtt
  state_topic: 'home/sensor1'
  name: 'Temperature'
  unit_of_measurement: '°C'
  value_template: '{{ value_json.temperature }}'
        
- platform: mqtt
  state_topic: 'home/sensor1'
  name: 'Humidity'
  unit_of_measurement: '%'
  value_template: '{{ value_json.humidity }}'

The UFT8 error means you have the wrong character set or the editor you are using is outputing an incorrect char for your language I think. I think if you get rid of the ‘°C’ and make it ‘C’ it will probably work. Failing that you need to save your files in UTF-8 format with whatever editor you are using. Hopefully that will help you out :slight_smile:

2 Likes

Thank you, you’re right. Created the file through nano, all is well now.