Scan Intervall?

Hey Guys,

I’m new on HA. I want to setup my Kasa HS110. I see the Power Consum in the Graph, but i want that is near realtime. 30sec for new Data is to long. 10sek are really better for my setup.
I find that “scan_intervall” can change that time, but if i type it in my code, i become a error.

“Invalid config for [sensor.template]: [scan_interval] is an invalid option for [sensor.template]. Check: sensor.template->sensors->switch_mark_ampere->scan_interval. (See ?, line ?).”

Original Code with 30sec.

sensor:
  - platform: template
    sensors:
      switch_mark_ampere:
        friendly_name_template: "{{ states.switch.mark.name}} Strom"
        value_template: '{{ states.switch.mark.attributes["current_a"] | float }}'
        unit_of_measurement: 'A'
      switch_mark_watt:
        friendly_name_template: "{{ states.switch.mark.name}} Leistung"
        value_template: '{{ states.switch.mark.attributes["current_power_w"] | float }}'
        unit_of_measurement: 'W'
      switch_mark_total_kwh:
        friendly_name_template: "{{ states.switch.mark.name}} Gesamtverbrauch"
        value_template: '{{ states.switch.mark.attributes["total_energy_kwh"] | float }}'
        unit_of_measurement: 'kWh'
      switch_mark_heute_kwh:
        friendly_name_template: "{{ states.switch.mark.name}} Tagesverbrauch"
        value_template: '{{ states.switch.mark.attributes["today_energy_kwh"] | float }}'
        unit_of_measurement: 'kWh'

Code with Error

sensor:
  - platform: template
    sensors:
      switch_mark_ampere:
        friendly_name_template: "{{ states.switch.mark.name}} Strom"
        value_template: '{{ states.switch.mark.attributes["current_a"] | float }}'
        unit_of_measurement: 'A'
        scan_interval: 10
      switch_mark_watt:
        friendly_name_template: "{{ states.switch.mark.name}} Leistung"
        value_template: '{{ states.switch.mark.attributes["current_power_w"] | float }}'
        unit_of_measurement: 'W'
        scan_interval: 10
      switch_mark_total_kwh:
        friendly_name_template: "{{ states.switch.mark.name}} Gesamtverbrauch"
        value_template: '{{ states.switch.mark.attributes["total_energy_kwh"] | float }}'
        unit_of_measurement: 'kWh'
        scan_interval: 10
      switch_mark_heute_kwh:
        friendly_name_template: "{{ states.switch.mark.name}} Tagesverbrauch"
        value_template: '{{ states.switch.mark.attributes["today_energy_kwh"] | float }}'
        unit_of_measurement: 'kWh'
        scan_interval: 10

Template Sensor does not support scan_internal.

You can redesign your Template Sensors to use the new Trigger-based Template Sensors. You can trigger them using a Time Pattern Trigger set to every 10 seconds.

I edit the Code with that

It looks like

template:
  - trigger:
      - platform: time_pattern
        seconds: "/10"
    sensor:
      switch_mark_watt:
        friendly_name_template: "{{ states.switch.mark.name}} Leistung"
        value_template: '{{ states.switch.mark.attributes["current_power_w"] | float }}'
        unit_of_measurement: 'W'

The Configuration says its all fine. But the Sensor doesnt show in the panel or in the entity list.

Trigger-based Template Sensors are configured differently (see documentation).

Try this:

template:
  - trigger:
      - platform: time_pattern
        seconds: "/10"
    sensor:
      - name: "{{ states.switch.mark.name}} Leistung"
        state: '{{ states.switch.mark.attributes["current_power_w"] | float }}'
        unit_of_measurement: 'W'

In addition, ensure you execute Configuration > Server Control > Reload Template Entities to load the new sensor.

1 Like