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

Use templating in sensor

$
0
0

@Djiest wrote:

Is it possible to use templating in a sensor? I have the following

  - platform: google_travel_time
    name: Morning Commute
    scan_interval: >-
      {% if is_state("binary_sensor.workday_sensor", "on") 
        and now().hour > 7 and now().hour < 9 -%}
        480
      {% else %}
        10000
      {% endif %}
    api_key: !secret google_maps_api
    origin: zone.home
    destination: zone.work

but when I check the config I get

Invalid config for [sensor]: offset {% if is_state("binary_sensor.workday_sensor", "on") 
  and now().hour > 7 and now().hour < 9 -%}
  480
{% else %}
  10000
{% endif %} should be format 'HH:MM' or 'HH:MM:SS' for dictionary value @ data['scan_interval']. Got None. (See ?, line ?).

Posts: 5

Participants: 3

Read full topic


Viewing all articles
Browse latest Browse all 95919

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>