Washing Machine HA - Node-Red Setup ESPhome Sonoff POW R2 with Amazon Polly 60 Voices

*** UPDATE **
This has been reworked to include all 60 Voices available on Amazon Polly which only works on Announce not TTS.
Between 8:00am - 9:00pm (no Whisper) outside of those hours they Whisper
Note (Joanna & Matthew are both Newscaster and Conversational Style so they don’t seem to be able to Whisper) reason there on the bottom of the list and there is two random generators.
Simplied the flow with less nodes.


I thought i would share my setup on the washing maching notification. i’m not worried about power usage as no matter what the clothes need to be washed

esphome:
  name: washing_machine
  platform: ESP8266
  board: esp01_1m
  on_boot:
    priority: -10
    then:
      - switch.turn_on: relay

binary_sensor:
  - platform: gpio
    pin:
      number: GPIO0
      mode: INPUT_PULLUP
      inverted: True
    name: "Washing Machine Basic Button"
    internal: true
  - platform: status
    name: "Washing Machine Status"

switch:
  - platform: gpio
    name: "Washing Machine Power"
    pin: GPIO12
    id: relay
  - platform: template
    name: "Washing Machine On"
    optimistic: true
  - platform: template
    name: "Washing Machine Cycle"
    optimistic: true

status_led:
  pin:
    number: GPIO13
    inverted: yes
    
uart:
  rx_pin: RX
  baud_rate: 4800

sensor:
  - platform: cse7766
    current:
      name: "Washing Machine Current"
    voltage:
      name: "Washing Machine Voltage"
    power:
      name: "Washing Machine Power"

that is pretty much straight from the website except for turning the relay on at boot
which i set so even with HA being down then there will always be power at the power point.
and the addition of 2 template switches that i used to set the state of the washing machine in the automation. Washing Machine On, Washing Machine Cycle. I could have used variables in node-red but I wanted HA to be aware of the state as well in case i want to do something elsewhere in HA.
so the logic is when the Power is above 0 and below 10watts then the machine has been switched on and the automation sets the template switch to on
when the Power is above 10 watts then the machine is both on and in a cycle the automation sets the cycle switch to on. once the Power Level gets back down to 0 watts being the machine has finished it checks to see if the cycle switch is on (cause you could just have turned on the the machine to open the door and then turned it off) if it was on then it turns it off, sends an announcement through alexa and switches the On switch to off.

Screenshot%20from%202019-05-22%2012-13-25

Node Red flow

[{"id":"7a34c540.8f84c4","type":"tab","label":"washing machine","disabled":false,"info":""},{"id":"dc6083be.ec2ad8","type":"api-call-service","z":"7a34c540.8f84c4","name":"washing off","server":"ef392d83.86c5a","version":1,"service_domain":"switch","service":"turn_off","entityId":"switch.washing_machine_on","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":550,"y":120,"wires":[[]]},{"id":"b1547d02.33153","type":"switch","z":"7a34c540.8f84c4","name":"","property":"payload","propertyType":"msg","rules":[{"t":"gt","v":"1.0","vt":"num"},{"t":"eq","v":"0","vt":"num"},{"t":"gt","v":"10","vt":"num"}],"checkall":"true","repair":false,"outputs":3,"x":90,"y":120,"wires":[["69656173.a925"],["b0504927.e67368"],["5fbd75ca.f4ffb4"]]},{"id":"69656173.a925","type":"api-call-service","z":"7a34c540.8f84c4","name":"washing on","server":"ef392d83.86c5a","version":"1","service_domain":"switch","service":"turn_on","entityId":"switch.washing_machine_on","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":310,"y":20,"wires":[[]]},{"id":"5fbd75ca.f4ffb4","type":"api-call-service","z":"7a34c540.8f84c4","name":"cycle on","server":"ef392d83.86c5a","version":"1","service_domain":"switch","service":"turn_on","entityId":"switch.washing_machine_cycle","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":240,"y":160,"wires":[[]]},{"id":"b0504927.e67368","type":"api-current-state","z":"7a34c540.8f84c4","name":"Cycle Switch State","server":"ef392d83.86c5a","version":1,"outputs":2,"halt_if":"true","halt_if_type":"bool","halt_if_compare":"is","override_topic":false,"entity_id":"switch.washing_machine_cycle","state_type":"habool","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":310,"y":100,"wires":[["3d01cc1a.0527c4"],["dc6083be.ec2ad8"]]},{"id":"3d01cc1a.0527c4","type":"api-call-service","z":"7a34c540.8f84c4","name":"cycle off","server":"ef392d83.86c5a","version":1,"service_domain":"switch","service":"turn_off","entityId":"switch.washing_machine_cycle","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":460,"y":40,"wires":[["70d84e64.2478b8"]]},{"id":"80540aed.a59958","type":"server-state-changed","z":"7a34c540.8f84c4","name":"Washing Power","server":"ef392d83.86c5a","version":"1","entityidfilter":"sensor.washing_machine_power","entityidfiltertype":"exact","outputinitially":true,"state_type":"num","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"x":100,"y":40,"wires":[["b1547d02.33153"]]},{"id":"70d84e64.2478b8","type":"time-range-switch","z":"7a34c540.8f84c4","name":"9:00am-9:00pm","lat":"-33.96041","lon":"151.02968","startTime":"09:00","endTime":"21:00","startOffset":0,"endOffset":0,"x":640,"y":40,"wires":[["dc6083be.ec2ad8","5bb98bda.a53244"],["dc6083be.ec2ad8","721504db.408c24"]]},{"id":"d6c09e60.1932b","type":"api-call-service","z":"7a34c540.8f84c4","name":"Nofity the House Hold","server":"ef392d83.86c5a","version":1,"debugenabled":false,"service_domain":"notify","service":"alexa_media","entityId":"","data":"{\"data\":{\"type\":\"announce\",\"method\":\"all\"},\"message\":\"<voice name='{{states.input_select.alexa_voice_tag}}'>This is {{states.input_select.alexa_voice_tag}}. The Washing Machine is Now Finished</voice>\",\"target\":[\"media_player.kitchen\",\"media_player.george_s_echo_show\",\"media_player.living_room_right\",\"media_player.echo_plus\",\"media_player.sunroom_left\",\"media_player.main_bathroom\"]}","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":1220,"y":160,"wires":[[]]},{"id":"82f43707.c51098","type":"api-call-service","z":"7a34c540.8f84c4","name":"{\"option\" : \"{{payload}}\"}","server":"ef392d83.86c5a","version":1,"debugenabled":false,"service_domain":"input_select","service":"select_option","entityId":"input_select.alexa_voice_tag","data":"{\"option\" : \"{{payload}}\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1230,"y":100,"wires":[["abc6aefe.b22ca8"]]},{"id":"d9863a33.e26258","type":"api-render-template","z":"7a34c540.8f84c4","name":"Template from HA","server":"ef392d83.86c5a","template":"{{states.input_select.alexa_voice_tag.attributes['options'][states.input_number.alexa_voice_number_box.state | int]}}","resultsLocation":"payload","resultsLocationType":"msg","templateLocation":"template","templateLocationType":"msg","x":1230,"y":40,"wires":[["82f43707.c51098"]]},{"id":"5bb98bda.a53244","type":"random","z":"7a34c540.8f84c4","name":"0 - 60","low":"0","high":"60","inte":"true","property":"payload","x":830,"y":20,"wires":[["1af024f8.72a943"]]},{"id":"1af024f8.72a943","type":"api-call-service","z":"7a34c540.8f84c4","name":"{\"value\": payload}","server":"ef392d83.86c5a","version":1,"debugenabled":false,"service_domain":"input_number","service":"set_value","entityId":"input_number.alexa_voice_number_box","data":"{\"value\": payload}","dataType":"jsonata","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":1010,"y":40,"wires":[["d9863a33.e26258"]]},{"id":"ac4f2a9d.9e139","type":"api-call-service","z":"7a34c540.8f84c4","name":"Whispher the House Hold","server":"ef392d83.86c5a","version":1,"debugenabled":false,"service_domain":"notify","service":"alexa_media","entityId":"","data":"{\"data\":{\"type\":\"announce\",\"method\":\"all\"},\"title\":\"From the Laundry Room\",\"message\":\"<amazon:effect name='whispered'><voice name='{{states.input_select.alexa_voice_tag}}'>This is {{states.input_select.alexa_voice_tag}}. The Washing Machine is Now Finished</voice></amazon:effect>\",\"target\":[\"media_player.kitchen\",\"media_player.george_s_echo_show\",\"media_player.living_room_right\",\"media_player.echo_plus\",\"media_player.sunroom_left\",\"media_player.main_bathroom\"]}","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":1230,"y":220,"wires":[[]]},{"id":"721504db.408c24","type":"random","z":"7a34c540.8f84c4","name":"0 - 58","low":"0","high":"58","inte":"true","property":"payload","x":830,"y":80,"wires":[["1af024f8.72a943"]]},{"id":"abc6aefe.b22ca8","type":"time-range-switch","z":"7a34c540.8f84c4","name":"9:00am-9:00pm","lat":"-33.96041","lon":"151.02968","startTime":"09:00","endTime":"21:00","startOffset":0,"endOffset":0,"x":860,"y":140,"wires":[["d6c09e60.1932b"],["ac4f2a9d.9e139"]]},{"id":"730b6880.b37138","type":"inject","z":"7a34c540.8f84c4","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":360,"y":220,"wires":[["70d84e64.2478b8"]]},{"id":"ef392d83.86c5a","type":"server","z":"","name":"Home Assistant","legacy":false,"hassio":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]
configuration.yaml:
input_select:
  alexa_voice_tag:
    name: 'Alexa Polly Voices '
    options:
    - 'Aditi'
    - 'Amy'
    - 'Astrid'
    - 'Bianca'
    - 'Brian'
    - 'Camila'
    - 'Carla'
    - 'Carmen'
    - 'Celine'
    - 'Chantal'
    - 'Conchita'
    - 'Cristiano'
    - 'Dora'
    - 'Emma'
    - 'Enrique'
    - 'Ewa'
    - 'Filiz'
    - 'Geraint'
    - 'Giorgio'
    - 'Gwyneth'
    - 'Hans'
    - 'Hindi'
    - 'Ines'
    - 'Ivy'
    - 'Jacek'
    - 'Jan'
    - 'Joey'
    - 'Justin'
    - 'Karl'
    - 'Kendra'
    - 'Kimberly'
    - 'Lea'
    - 'Liv'
    - 'Lotte'
    - 'Lucia'
    - 'Lupe'
    - 'Mads'
    - 'Maja'
    - 'Marlene'
    - 'Mathieu'
    - 'Maxim'
    - 'Mia'
    - 'Miguel'
    - 'Mizuki'
    - 'Naja'
    - 'Nicole'
    - 'Penelope'
    - 'Raveena'
    - 'Ricardo'
    - 'Ruben'
    - 'Russell'
    - 'Salli'
    - 'Seoyeon'
    - 'Takumi'
    - 'Tatyana'
    - 'Vicki'
    - 'Vitoria'
    - 'Zeina'
    - 'Zhiyu'
    - 'Joanna'
    - 'Matthew'
    initial: 'Nicole'

input_number:
  alexa_voice_number_box:
    min: 0
    max: 60
    initial: 48
    step: 1
    mode: box
6 Likes

Nice one

But can u format you code correctly make easer for us to read it also could u copy the node red bit we can just copy and it’s in our node red

sorry first time post

I will be updating this shortly to include the full 60 voices that Amazon Polly has.
As they say variety is the spice of life.
i’m going to also look at using the whispered effect for announcements outside the current time periods
i think it will be cool for them to whisper “Hey is anyone awake, the washing machine, its finished”. for late at night and something different for the early morning. “I don’t want to wake everyone up, but the washing machine has finished.”

1 Like

***** Update Completed ****

Thank you! Finally I have a way to send voice to echo dot from node-red.
Question, where can I find the documents for the syntax?
I tried to fill the entity_id (I only have one media player), and remove the target in the json data, then it error out

"Call-service API error. Error Message: extra keys not allowed @ data['entity_id']"

Post your flow

here are some examples

first uses the notify.alexa_media+alexa_id service
second doesnt
third is doing it to several echo’s
forth is sticking the payload into the message ( state of the light )

image

here is the flow

[{"id":"a5282acc.a87578","type":"tab","label":"Flow 8","disabled":false,"info":""},{"id":"8810bc89.2c733","type":"api-call-service","z":"a5282acc.a87578","name":"Using notify.alexa_media + alexa_id service ","server":"ef392d83.86c5a","version":1,"debugenabled":false,"service_domain":"notify","service":"alexa_media_office_echo_plus","entityId":"","data":"{\"data\":{\"type\":\"announce\",\"method\":\"all\"},\"message\":\"The  Master Bedroom Fan Is Now Set To Low\"}","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":590,"y":120,"wires":[[]]},{"id":"bec29928.827238","type":"inject","z":"a5282acc.a87578","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":260,"y":140,"wires":[["8810bc89.2c733"]]},{"id":"17945342.cca55d","type":"api-call-service","z":"a5282acc.a87578","name":"Using notify.alexa_media","server":"ef392d83.86c5a","version":1,"debugenabled":false,"service_domain":"notify","service":"alexa_media","entityId":"","data":"{\"data\":{\"type\":\"announce\",\"method\":\"all\"},\"message\":\"The  Master Bedroom Fan Is Now Set To Low\",\"target\":\"media_player.office_echo_plus\"}","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":570,"y":200,"wires":[[]]},{"id":"d168746f.e030c8","type":"inject","z":"a5282acc.a87578","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":260,"y":200,"wires":[["17945342.cca55d"]]},{"id":"3d4ec6eb.d78e9a","type":"api-call-service","z":"a5282acc.a87578","name":"Using Alexa Media to several echo's","server":"ef392d83.86c5a","version":1,"debugenabled":false,"service_domain":"notify","service":"alexa_media","entityId":"","data":"{\"data\":{\"type\":\"announce\",\"method\":\"all\"},\"message\":\"The  Master Bedroom Fan Is Now Set To Low\",\"target\":[\"media_player.office_echo_plus\",\"media_player.office_echo_plus_2\"]}","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":590,"y":260,"wires":[[]]},{"id":"a8a1ca01.653298","type":"inject","z":"a5282acc.a87578","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":260,"y":260,"wires":[["3d4ec6eb.d78e9a"]]},{"id":"e97d10a.217bdf","type":"api-call-service","z":"a5282acc.a87578","name":"Just tts light off or on","server":"ef392d83.86c5a","version":1,"debugenabled":false,"service_domain":"notify","service":"alexa_media","entityId":"","data":"{\"data\":{\"type\":\"tts\"},\"message\":\"The  Office LED light is Now {{payload}}\",\"target\":[\"media_player.office_echo_plus\"]}","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":720,"y":360,"wires":[[]]},{"id":"ed6dc03c.a8991","type":"server-state-changed","z":"a5282acc.a87578","name":"","server":"ef392d83.86c5a","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"light.extended_color_light_2","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"x":330,"y":360,"wires":[["e97d10a.217bdf"],["e97d10a.217bdf"]]},{"id":"ef392d83.86c5a","type":"server","z":"","name":"Home Assistant","legacy":false,"hassio":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]
2 Likes

Awesome, thanks for sharing!

I have a similar setup (sonoff s31, esphome, nodered, 10sec update interval), except I use telegram for notifications. I figured I would mention a solution I came up with to washing machines that have peculiar power profiles. My high efficiency washer idles at 4W all day when off, it stays >=12W for the most part during a wash cycle, and that drops to 11W after a load finishes up and the tub light turns on. It takes another 15min for that tub light to turn off and drop back to 4W.

So, I had to use >=12W as my condition to ensure the notification wasn’t delayed 15min. Unfortunately, toward the end of the spin cycle, there are times during the wash cycle where power dips briefly below 12W. So frustrating! Fortunately node-red makes these things easy… I added a delay to the off condition that resets itself if power goes >=12W. For my washer, I settled on a delay of 12sec. This was slow enough to ignore those moments of 11W during the cycle, without being so long that my telegrams are unecessarily delayed.

Cool, well mine isnt exact Either. It actually takes a few minutes after the washer has turned off, the sonoff is still registering power. I think the heater element is still returning a level of current till it cools.
But at least its not an hour or so cause we all forgot we put a load on.

Thanks! The code is for the third node only in the screenshot, could you copy the whole flow?

Sorry im not understanding what your asking.

the flow code you posted above only for one example “Using Alexa Media to several echo’s”, I’d like to see config for other example in your screenshot too.

Oh i see i accidentally had that node highlighted when i exported it and it only exported the node, i didnt even look.

Done complete flow

2 Likes

thank you!

Harry,

I cannot get the alexa tts to work. It keeps giving me API error service not found. Do I have to configure anything in the alexa_media code in the config yaml?

Scratch that, I found the information on the wiki and found my mistake!

Thanks!
Joshua

Anyone using an Echo show and seeing the parameters showing up on the announcement text?

Yes it does and its mentioned in the documentation that is what will happen.
I sure I said that in my original post that I didn’t care it showing. If you do you just need to set it to speak rather than show or all.

Notes:

  1. When using SSML it is best to have method as “speak”, rather than “show” or “all”, as otherwise the SSML markup will be displayed on devices with a screen;

But you can now do this as well

Set Echo Show background (versions >= 2.10.0)

You can set the background of an Echo Show using the media_player.play_media service with media_content_type set to image . The url must be a valid https image to be accepted. To undo, follow these instructions.

Examples

`

entity_id: media_player.echo_show' 
media_content_id: "https://home-assistant.io/images/cast/splash.png" 
media_content_type: image

which would be better

Hello everyone,

Can I share the new code? And updated.

I use “Shelly 1PM”

Thank you !