Starting dishwasher when electricity is cheap

I am a happy user of Control a water heater and ground source heat pump based on cheap hours of spot priced electricity - #12 by masipila by @masipila and the Home Connect OH binding. I have a Siemens dishwasher that I currently configure manually to start at night at the lowest electricity price using an OpenHAB rule. I would want this rule to run automatically when the electricity price is lowest. The script needs to do three things: Turn the dishwasher on, select the program and start the dishwasher.
My current rule looks like this:


How to proceed?

What is yor actual question? How to know when to run these rules or something else?

Have you tried searching for “dishwasher”? :wink:

https://community.openhab.org/search?q=dishwasher

1 Like

This is where I am at right now. Will report if this works.

dh = require('xxxx/date-helper.js');
wh = require('xxxx/waterheater.js');
influx = require('xxxx/influx.js');

start = dh.getCurrentHour();
control = influx.getCurrentControl('drier_control', start);

tiskikoneenVirta = items.getItem("Siemens_Astianpesukone_012020388740013427_Virta");
tiskiKoneenOhjelma = items.getItem("Siemens_Astianpesukone_012020388740013427_Selected_Program");
tiskikoneenKaynnistys = items.getItem("Siemens_Astianpesukone_012020388740013427_Program_Actions");

// Check if the dishwasher is off and should be turned on.
if (tiskikoneenVirta.state == 'OFF' && control == 1) {
  tiskikoneenVirta.sendCommand('ON');
// Set dishwashing program
  tiskikoneenOhjelma.sendCommand('Dishcare.Dishwasher.Program.Auto2');
// Start dishwasher
  tiskikoneenKaynnistys.sendCommand('start'); 
  console.log('Dishwasher: Started.');
}
else {
  console.log('Dishwasher: No state change needed.');
}

Looks about correct.

  1. You don’t need to included the waterheater js here.

  2. You need another rule which will save the control point for your dishwasher. You can call that for example dishwasher_control.

  3. And then you need to change the drier_control to dishwasher_control from this rule.

So to summarize: you’ll need two rules. One that determines the 1/0 control points. And this one which will check the control points if current hour is the one when you want to start the dishwasher.

1 Like

Thanks for the feedback! This code of yours lends itself to plenty of applications of spot price control.

1 Like

Rule to save control points for dishwasher:

dh = require('xxx/date-helper.js');
wh = require('xxx/waterheater.js');
influx = require('xxx/influx.js');

start = dh.getMidnight('start');
stop = dh.getMidnight('stop');

// Determine cheap hours and write control values to the database
hours = 4;
points = wh.determineHours(start, stop, hours);
influx.writePoints('dishwasher_control', points);

Rule to check if dishwasher needs to start:

dh = require('xxx/date-helper.js');
influx = require('xxx/influx.js');

start = dh.getCurrentHour();
control = influx.getCurrentControl('dishwasher_control', start);

tiskikoneenOvi = items.getItem("Siemens_Astianpesukone_012020388740013427_Door_State");
tiskikoneenVirta = items.getItem("Siemens_Astianpesukone_012020388740013427_Virta");
tiskiKoneenOhjelma = items.getItem("Siemens_Astianpesukone_012020388740013427_Selected_Program");
tiskikoneenKaynnistys = items.getItem("Siemens_Astianpesukone_012020388740013427_Program_Actions");

// Check if the dishwasher is off and should be turned on.
if (tiskikoneenOvi.state == 'CLOSED' && tiskikoneenVirta.state == 'OFF' && control == 1) {
  tiskikoneenVirta.sendCommand('ON');
// Set dishwashing program
  tiskikoneenOhjelma.sendCommand('Dishcare.Dishwasher.Program.Auto2');
// Start dishwasher
  tiskikoneenKaynnistys.sendCommand('start'); 
// Repeat the command to actually start the dishwasher.
  tiskikoneenKaynnistys.sendCommand('start'); 
  console.log('Dishwasher: Started.');
}
else {
  console.log('Dishwasher: No state change needed.');
}

This is running now, lets see what happens.

This should work.

Only comment is that if you are only interested to start the dish washer when the cheapest hour starts, you could set the number of hours to 1 instead of 4 in your control point script.

This is OK even if your program would last longer than 1 hour, because note of your rule logic will turn the machine off, you only have logic to turn it on.

Just a thought…

Markus

P.s. The name “waterheater.js” is a terrible name for this script but whatever, it works… Much better name would be “control-point-optimizer.js” or something similar because that’s what it actually is… This again proves the old story to be true that there are only two difficult things in computer science: 1) Finding good names, 2) Invalidating cache and 3) offset by one. :slight_smile:

I found out the dishwasher ends up waiting for the start command infinitely. Repeating the start command starts the device. Edited the code above to reflect this change.