Laundry is finished TTS

Could you awesome peeps here give me a hand please? I just cant get it through to 100% :wink:
The boolean sets to on when the machine starts, but doesnt turn it off when finished, so somewhere in between is something wrong.
If I manually turn if off sonos do the TTS. It seems like the timer isn’t started like supposed to, and therefor doesnt finish


 # Washer starts, W goes above 5, boolean sets to on
 # If the machine isnt finished, it will go above 5W and cancel any active timer
- action:
  - entity_id: input_boolean.tvattmaskin
    service: input_boolean.turn_on
  - entity_id: timer.tvattmaskin
    service: timer.cancel
  alias: TvÀttmaskinen startar
  condition: []
  id: 'Tvattmaskin1'
  trigger:
   - platform: template
     value_template: '{{ states.switch.tvattmaskinen_3.attributes.current_power_w > 5 }}'
# Washer pauses, (or ends) W goes below 5W, Timer starts for 2min.
- action:
  - service: timer.start
    entity_id: timer.tvattmaskin
  alias: TvÀttmaskinen stannar
  condition: []
  id: 'Tvattmaskin2'
  trigger:
   - platform: template
     value_template: '{{ states.switch.tvattmaskinen_3.attributes.current_power_w < 5 }}'
# The washer was finished, timer ends and will set the boolean to off
- action:
  - service: input_boolean.turn_off
    entity_id: input_boolean.tvattmaskin
  alias: TvÀttmaskinen stannar
  condition: []
  id: 'Tvattmaskin3'
  trigger:
  - platform: event
    event_type: timer.finished
    event_data:
      entity_id: timer.tvattmaskin
# The boolean sets to off, and Sonos tells us the washer is done.
- action:
  - service: script.say
     data:
       delay: 00:00:05
       volume: 0.2
       message: TvÀttmaskinen Àr klar
       where: media_player.vardagsrum
  alias: TvÀttmaskinen talar
  condition: []
  id: 'Tvattmaskin4'
  trigger:
    - platform: state
      entity_id: input_boolean.tvattmaskin
      to: 'off'

I haven’t looked through it all, but I think the delay amount should be in quotes and out of the data section, so something like this:

- action:
    delay: '00:00:05'
  - service: script.say
     data:
       volume: 0.2
       message: TvÀttmaskinen Àr klar
       where: media_player.vardagsrum

Thanks for your input
The boolean isn’t switching off when the laundry is done, if I turn it off manually in the frontend the Sonos speaks as supposed. So I tripped somewhere on the timer would be my guess

Sadly the snapshot/restore doesnt work on my Sonos right now, but thats another issue to be fixed later.

I approched this a bit differently.

Created a template sensor that sets the washer to ON if power consumption is more then 2.5W. Adjust to fit your machine.

sensor:
  - platform: template
    sensors:
      vaskemaskin:
        value_template: >-
            {% if states('sensor.fibaro_powerplug_vaskemaskin_power') | float > 2.5 %}
                pÄ
            {% else %}
                av
            {%- endif %}
        icon_template: '{% if is_state("sensor.vaskemaskin", "pÄ") %}mdi:power{% else %}mdi:sleep{% endif %}'
        friendly_name: 'Vaskemaskin'

Then just a simple automation to send sonos tts after its been off for 30secs:

automation:
  - alias: 'TTS when washer done'
    initial_state: True
    trigger:
      platform: state
      entity_id: sensor.vaskemaskin
      from: 'pÄ'
      to: 'av'
      for:
        seconds: 30
    action:
      - service: script.sonos_tts
        data:
          sonos_entity: media_player.gang
          volume: 0.3
          message: 'Vaskemaskinen er ferdig'
          delay: '00:00:05'

Hope this helps :slight_smile:

1 Like

Thanks, I will try this tomorrow after work :grin:

Tried your suggestion but still no success,
Seems like something is still broken
 trying the template engine

TvÀttmaskinen drar just nu: {{ states.switch.tvattmaskinen_3.attributes.current_power_w }} W
gives me the output:
TvÀttmaskinen drar just nu: 4.355 W
(testing with a bulb right now)

So by creating:

{% if ("states.switch.tvattmaskinen_3.attributes.current_power_w" '> 5') %} PĂ„
{% else %} Av
{% endif %}

Gives me the output:
On
Which is wrong
 ?

And trying with


Det betyder att tvÀttmaskinen Àr: {% if is_state_attr('switch.tvattmaskinen_3', 'current_power_w', 'above: 4')  %}
                PĂ„
            {% else %}
                av
            {%- endif %}

Gives me AV


What on earth am i templating wrong with this switch? It is reporting the wattage correctly.

I think you shouldn’t have the condition in string. Remove the quotes. You could also try to cast power value to int before checking condition.

There’s actually a much simpler solution that doesn’t require Booleans.
Have a look at the washing machine example at the bottom of this.

Add to your notification automation

1 Like

That’s about the new approach I need help templating
 I just can’t get it to work.
As my switch reports W correctly and I’ve tried a few different approaches, I just cant get the condition to work.

Tried to work without quotes and switched the positions, and no luck
I just don’t understand why HA can’t get the condition right.

Here it is. the sensor and notification automation. My sensor is the Sonoff POW switch.

https://hastebin.com/ayepovilop.cs

in the template sensor, this sensor ( states.sensor.washing_power.state) is the raw data from the switch.

I use the same template as @sjabby it works fine. Try this;

if states('states.switch.tvattmaskinen_3.attributes.current_power_w') | float > 5 %}
PĂ„
{% else %}
Av
{% endif %}

Trying:

TvÀttmaskinen drar {{ states.switch.tvattmaskinen_3.attributes.current_power_w }} W
{% if states('states.switch.tvattmaskinen_3.attributes.current_power_w') | float > 4 %}
PĂ„
{% else %}
Av

Gives me:
TvÀttmaskinen drar 4.398 W

Av

I just can’t understand why HA is doing something wrong with the information it gets from the attribute.
It’s clearly seeing the current wattage (thats why I use the first line)

testing with changing the condition less/more
 (testing with a bulb so the wattage does vary i little from time to time)

TvÀttmaskinen drar {{ states.switch.tvattmaskinen_3.attributes.current_power_w }} W

{% if states('states.switch.tvattmaskinen_3.attributes.current_power_w') | float > 4 %}
Av
{% else %}
PĂ„
{% endif %}

TvÀttmaskinen drar 4.308 W

PĂ„

TvÀttmaskinen drar {{ states.switch.tvattmaskinen_3.attributes.current_power_w }} W

{% if states('states.switch.tvattmaskinen_3.attributes.current_power_w') | float < 4 %}
Av
{% else %}
PĂ„
{% endif %}

Gives:
TvÀttmaskinen drar 4.363 W

Av

It’s not HA doing something wrong here
 :wink:

Not sure


{% if ('states.switch.tvattmaskinen_3.attributes.current_power_w') | float > 5 %}
PĂ„
{% else %}
Av
{% endif %}

That gives me:
TvÀttmaskinen drar 4.124 Watt

Av
Which indeed is true! yay :slight_smile: alright, for testing purposes I lower the number to 4 to see if it reports PÄ 

But still it gives:
TvÀttmaskinen drar 4.173 Watt

Av

I have a feeling that it jumps to the else argument as the value aint exactly right in the if argument


Yeah, you need to play around with the sensor as I can’t help you with that. Try

{% if states.switch.tvattmaskinen_3.attributes.current_power_w | float > 5 %}

look at ya :wink: awesome

{% if states.switch.tvattmaskinen_3.attributes.current_power_w | float > 5 %}PÅ
{% else %}
AV
{% endif %}

{% if states.switch.tvattmaskinen_3.attributes.current_power_w | float > 4 %}PÅ
{% else %}
AV
{% endif %}

AV

PÅ

Wow, I’m surpized myself :wink: Glad it works