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

Device_tracker state automation constantly triggering

$
0
0

@sebk-666 wrote:

Hi,
I want to build an automation that turns on my laptop’s docking station when the laptop is on and off when the laptop is off / in standby.

To spare me some repetition, I templated this like so:

alias: '[Power] Switch Thinkpad Dock with Thinkpad State'
trigger:
  - platform: state
    entity_id: device_tracker.thinkpad
action:
  service_template: >
    {%if is_state('device_tracker.thinkpad', 'home') %}
    switch.turn_on
    {%else%}
    switch.turn_off
    {%endif%}
  data:
    entity_id: switch.thinkpad

The problem is, that this triggers every 5s or so and not only when the device_tracker state changes.
Does anyone know why that is?

I can split this into two automations for the homenot_home and not_homehome state transitions and it will work as expected, but I’d rather have a single piece of code to maintain.

Sebastian

Posts: 6

Participants: 3

Read full topic


Viewing all articles
Browse latest Browse all 101645

Trending Articles



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