If state of switch.graysonteamaker is "Brewed," only execute action once

# automations.yaml
- alias: Tea is done.
  trigger:
    platform: template
    value_template: '{% if states.switch.teamaker.attributes.state_detail == "Brewed"
      %}true{% endif %}'
  action:
  - service: light.turn_on
    entity_id: light.lr_flamps
    data:
      brightness: 128

As seen in code above, the execution of action works; however, once I turn off the light (light.lr_flamps), the light turns back on with an action executed again. The workaround I can do is to take the tea pot out of my coffee maker (I make tea, not coffee). If I suspect correctly, the action gets executed every minute when in “Brewed” state, so how can I tell Home Assistant to only execute the action once?

How about creating a Template Binary Sensor to indicate if the tea is brewed on not.

# binary_sensors.yaml
- platform: template
  sensors:
    tea_brewed:
      friendly_name: "Tea Brewed"
      entity_id: switch.teamaker
      value_template: "{{ state_attr('switch.teamaker', 'state_detail') == "Brewed" }}"

Modify the automation so it’s triggered exclusively when binary_sensor.tea_brewed changes state from off to on.

# automations.yaml
- alias: Tea is done.
  trigger:
    platform: state
    entity_id: binary_sensor.tea_brewed
    from: 'off'
    to: 'on'
  action:
  - service: light.turn_on
    entity_id: light.lr_flamps
    data:
      brightness: 128

I already have the template sensor:

- platform: template
  sensors:
    graysonteamaker_status:
      friendly_name: "Status of Grayson's Tea Maker"
      value_template: "{{ states.switch.teamaker.attributes.state_detail }}"

Although it’s just a sensor, not a binary sensor, as there are different states, such a “Ready,” “Refill,” and “Brewed.”

Maybe I should add a binary sensor in addition to the sensor I already have. Thanks.

In that case, you can use sensor.graysonteamaker_status in the automation and trigger when its state changes to Brewed.

# automations.yaml
- alias: Tea is done.
  trigger:
    platform: state
    entity_id: sensor.graysonteamaker_status
    to: 'Brewed'
  action:
  - service: light.turn_on
    entity_id: light.lr_flamps
    data:
      brightness: 128

Heh… Seems like I can just use a state instead of a template for automation.

(After a few minutes later…)

Hmm… I think my Wemo coffee maker (switch.graysonteamaker, 172.20.10.8) disconnects and reconnects to my Wi-Fi network, causing the “Brewed” state to be triggered again…

...
64 bytes from 172.20.10.8: icmp_seq=40 ttl=64 time=1.16 ms
64 bytes from 172.20.10.8: icmp_seq=41 ttl=64 time=1.30 ms
64 bytes from 172.20.10.8: icmp_seq=42 ttl=64 time=1.10 ms
64 bytes from 172.20.10.8: icmp_seq=43 ttl=64 time=2.88 ms
64 bytes from 172.20.10.8: icmp_seq=44 ttl=64 time=1.16 ms
64 bytes from 172.20.10.8: icmp_seq=45 ttl=64 time=1.14 ms
64 bytes from 172.20.10.8: icmp_seq=46 ttl=64 time=3.06 ms
64 bytes from 172.20.10.8: icmp_seq=47 ttl=64 time=1.12 ms
64 bytes from 172.20.10.8: icmp_seq=48 ttl=64 time=1.61 ms
64 bytes from 172.20.10.8: icmp_seq=49 ttl=64 time=1.11 ms
64 bytes from 172.20.10.8: icmp_seq=50 ttl=64 time=1.11 ms
64 bytes from 172.20.10.8: icmp_seq=51 ttl=64 time=1.08 ms
64 bytes from 172.20.10.8: icmp_seq=57 ttl=64 time=1.28 ms
64 bytes from 172.20.10.8: icmp_seq=62 ttl=64 time=1.96 ms
64 bytes from 172.20.10.8: icmp_seq=63 ttl=64 time=1.25 ms
64 bytes from 172.20.10.8: icmp_seq=64 ttl=64 time=1.10 ms
64 bytes from 172.20.10.8: icmp_seq=65 ttl=64 time=1.33 ms
64 bytes from 172.20.10.8: icmp_seq=66 ttl=64 time=8.83 ms
^C
--- 172.20.10.8 ping statistics ---
66 packets transmitted, 57 received, 13.6364% packet loss, time 326ms
rtt min/avg/max/mdev = 1.060/1.477/8.829/1.076 ms

...
64 bytes from 172.20.10.8: icmp_seq=117 ttl=64 time=2.69 ms
64 bytes from 172.20.10.8: icmp_seq=118 ttl=64 time=1.14 ms
64 bytes from 172.20.10.8: icmp_seq=119 ttl=64 time=1.10 ms
64 bytes from 172.20.10.8: icmp_seq=120 ttl=64 time=1.44 ms
64 bytes from 172.20.10.8: icmp_seq=126 ttl=64 time=10.8 ms
64 bytes from 172.20.10.8: icmp_seq=131 ttl=64 time=1.43 ms
64 bytes from 172.20.10.8: icmp_seq=132 ttl=64 time=1.46 ms
64 bytes from 172.20.10.8: icmp_seq=133 ttl=64 time=1.07 ms
^C
--- 172.20.10.8 ping statistics ---
133 packets transmitted, 113 received, 15.0376% packet loss, time 703ms
rtt min/avg/max/mdev = 1.043/1.552/10.796/1.170 ms

I’m not sure what my Mr. Coffee Smart Coffee Maker with Wemo is doing… Why is it disconnecting from my Wi-Fi network and reconnected back?

UniFi Controller reports that my tea maker (for brewing tea) has a Wi-Fi experience of 99%… I’m puzzled, as I do not assign a Wemo tea maker a default gateway. Only the IP address and subnet mask is given from my DHCP reservation and that’s it.

https://www.amazon.com/gp/product/B00LUFSSWG/ref=oh_aui_search_asin_title?ie=UTF8&psc=1

I purchased Mr. Coffee Wemo Coffee Maker in 2016.