Alert when Washing Machine Finished

logo

This rule template will create a rule that monitors the power consumption of a washing machine (for example, with a smart plug that can report consumption), and send an alert command when it gets below a threshold, meaning it has finished.

Configuration

Parameter Type Description
Power Item Item Item that holds the power (in watts) of the washing machine. Can be a quantity type (Number:Power).
Threshold Decimal When the power measurement was at or above the threshold and crosses below it, trigger the alert.
Alert Item Item Item to send a command to when the measured power gets below the threshold. For instance, a Hue light advanced Alert channel.
Alert Command Text Command to send to the alert item (for an item linked to a Hue light alert channel, LSELECT will flash the light for a few seconds).

Changelog

Version 0.1

  • initial release

Resources

uid: ysc:washing_machine_alert
label: Alert when Washing Machine Finished
description: This will monitor the power consumption of a washing machine and send an alert command when it gets below a threshold, meaning it has finished.
configDescriptions:
 - name: powerItem
   type: TEXT
   context: item
   label: Power Item
   required: true
   description: Item that holds the power (in watts) of the washing machine. Can be a quantity type (Number:Power).
 - name: threshold
   type: DECIMAL
   label: Threshold
   required: true
   defaultValue: 2
   description: When the power measurement was at or above the threshold and crosses below it, trigger the alert.
 - name: alertItem
   type: TEXT
   context: item
   label: Alert Item
   required: true
   description: Item to send a command to when the measured power gets below the threshold. For instance, a Hue light advanced Alert channel.
 - name: alertCommand
   type: TEXT
   label: Alert Command
   required: true
   defaultValue: LSELECT
   description: Command to send to the alert item (for an item linked to a Hue light alert channel, LSELECT will flash the light for a few seconds).
triggers:
 - id: "1"
   configuration:
     itemName: "{{powerItem}}"
     state: ""
   type: core.ItemStateChangeTrigger
conditions: []
actions:
 - inputs: {}
   id: "2"
   configuration:
     type: application/javascript
     script: |
       var from = parseFloat(oldState.toString().split(' ')[0]);
       var to = parseFloat(newState.toString().split(' ')[0]);

       print(from + '>' + to);

       if (to < {{threshold}} && from >= {{threshold}}) {
         events.sendCommand('{{alertItem}}', '{{alertCommand}}');
       }
   type: script.ScriptAction
5 Likes

Nice, I have created a binding that handles this as well as keeping track of the consumption. I never got it merged since I didn’t have support for gui similar to the pidcontroller, but I might convert it/add support if it’s of interest. This seems like a nice approach which solves the problem in simple manner.

Regards S

What do I need to specify in the alert item to send a telegram message?
I have the telegram bot up and running

Probably a rule that triggers when the alert Item is commanded that uses the Telegram actions to send the message.

Found it bu adapting your script slightly. thanks!

Continuing the discussion from Alert when Washing Machine Finished:

Hi Mr. Schaus
I like that Add-on you made.

But i need a little bit Help.

Could you tell me, how i could send an Notification over Broadcast to all devices Openhab is installed?
If you could tell me that, it would be very usefully for me!

Kind regards.

Mordi

Once the rule is created from this template, edit the Action, and modify the script to:

  1. declare the NotificationAction:
var notifications = Java.type('org.openhab.io.openhabcloud.NotificationAction');

docs here: Actions | openHAB

  1. use it in your script:
       if (to < {{threshold}} && from >= {{threshold}}) {
         // replace or overwrite: events.sendCommand('{{alertItem}}', '{{alertCommand}}');
         notifications.sendBroadcastNotification('message','icon','info');
       }

replace the events.sendCommand (or add a new statement alongside it).