Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 95414

More Splitting the config issues

$
0
0

@Malcolm_Smart wrote:

Help! I have split my switches into smaller YAML files and all good. But having a mare on teh sensors - a mix of template sensor and a binary RF mqtt sensor. It’s 0130hrs now here, so i have given up - hoping i may have some answers when i wake :slight_smile:

Configuration.yam

sensor: !include_dir_list sensor/

I have a folder called sensor with the following three files. The first two give me no problem, appear in my states list.

  platform: template
  sensors:
    next_dawn:
      friendly_name: "Dawn"
      value_template: >
        {% set n = now().timestamp() %}
        {% set sunrise = as_timestamp(state_attr("sun.sun" , "next_dawn") ) %}
        {% set secondsToSunrise = sunrise - n %}
        {% set hours = secondsToSunrise // 3600 %}
        {% set secondsToSunrise = secondsToSunrise - ( hours * 3600 ) %}
        {% set minutes = secondsToSunrise // 60 %}
        {% set secondsToSunrise = secondsToSunrise - ( minutes * 60 ) %}
        {{ '{:02}:{:02}:{:02}'.format(hours | int, minutes | int , secondsToSunrise | int) }}

The next one also works…

  platform: template
  sensors:
    next_bin_colour:
      friendly_name: "Next Bin Colour"
      value_template: >
       {% set week = now().strftime('%U') %}
       {% set weekEven = (week | int) % 2  %}
       {% if weekEven == 1%}BLUE{% else %}BLACK{% endif %}

but this one almost has me in tears - i just can’t get all three playing nicely…

  binary_sensor:
  - platform: mqtt
    state_topic: "tele/bridge/RESULT"
    name: 'Garage Door'
    value_template: '{{value_json.RfReceived.Data}}'
    payload_on: 'some code'
    payload_off: 'some other code'
    device_class: opening

It complains about various things - sometimes i can’t have on/off for payload. Other times i can’t have mapping if i move the ‘binary_sensor’ line. i had these three wokring in configuratoin.yaml - but struggling to break them outinto the sensors/ folder. I think it’s to do with a mix of sensor types or platform types - but my head is now full.

any help much appreciated - sorry for long post - but i am still new at this YAML stuff so wanted to give as much info as possible. Have also tried with include_dir_merge_list as well.

Posts: 3

Participants: 3

Read full topic


Viewing all articles
Browse latest Browse all 95414

Trending Articles