Duke Yin's Technology database

HomeAssistant实用自定义模板

Custom Templates

日夜晨昏传感器

sensor:
  - platform: template
    sensors:
      period_of_day:
        friendly_name: 'period of the day'
        value_template: >-
         {% if (as_timestamp(states.sun.sun.attributes.next_dusk)) - (as_timestamp(states.sun.sun.attributes.next_setting)) < 0 %}
           dusk
         {% elif (as_timestamp(states.sun.sun.attributes.next_rising)) - (as_timestamp(states.sun.sun.attributes.next_dawn)) < 0 %}
           dawn
         {% elif (states.sun.sun.attributes.elevation) < -4 %}
           night
         {% else %}
           day
         {% endif %}
        icon_template: >-
         {% if (as_timestamp(states.sun.sun.attributes.next_dusk)) - (as_timestamp(states.sun.sun.attributes.next_setting)) < 0 %}
           mdi:weather-sunset-down
         {% elif (as_timestamp(states.sun.sun.attributes.next_rising)) - (as_timestamp(states.sun.sun.attributes.next_dawn)) < 0 %}
           mdi:weather-sunset-up
         {% elif (states.sun.sun.attributes.elevation) < -4 %}
           mdi:weather-night
         {% else %}
           mdi:weather-sunny
         {% endif %}
        attribute_templates:
          color: >
            {% if is_state('sensor.period_of_day', 'dusk')  %}
              lime
            {% elif is_state('sensor.period_of_day', 'dawn') %}
              orange
            {% elif is_state('sensor.period_of_day', 'night') %}
              teal
            {% else %}
              yellow
            {% endif %}

允许本地网络反向代理

# Allow reserved proxy from local network
http:
  use_x_forwarded_for: true
  trusted_proxies:
    - 192.168.X.0/24
# Replace X for your local network range number eg. 192.168.3.0

#

发布评论

评论

标注 * 的为必填项。