Washing Machine State Machine

power
Tags: #<Tag:0x00007fe05d933588>

(Nathan Stratton) #11

Anyone else using GEMs and seeing 0s where you should see data?

2016-10-22 15:04:48.590 [INFO ] [runtime.busevents             ] - Circuit_C02 state updated to 0.0
2016-10-22 15:05:04.591 [INFO ] [runtime.busevents             ] - Circuit_C02 state updated to 0.0
2016-10-22 15:05:20.581 [INFO ] [runtime.busevents             ] - Circuit_C02 state updated to 2573.75
2016-10-22 15:05:36.582 [INFO ] [runtime.busevents             ] - Circuit_C02 state updated to 756.938
2016-10-22 15:06:15.584 [INFO ] [runtime.busevents             ] - Circuit_C02 state updated to 1220.462
2016-10-22 15:06:31.585 [INFO ] [runtime.busevents             ] - Circuit_C02 state updated to 1034.438
2016-10-22 15:06:47.586 [INFO ] [runtime.busevents             ] - Circuit_C02 state updated to 722.875
2016-10-22 15:07:03.587 [INFO ] [runtime.busevents             ] - Circuit_C02 state updated to 1022.625
2016-10-22 15:07:19.588 [INFO ] [runtime.busevents             ] - Circuit_C02 state updated to 241.0
2016-10-22 15:07:35.588 [INFO ] [runtime.busevents             ] - Circuit_C02 state updated to 1449.438
2016-10-22 15:07:51.589 [INFO ] [runtime.busevents             ] - Circuit_C02 state updated to 0.0
2016-10-22 15:08:07.590 [INFO ] [runtime.busevents             ] - Circuit_C02 state updated to 1683.625
2016-10-22 15:08:23.581 [INFO ] [runtime.busevents             ] - Circuit_C02 state updated to 0.0
2016-10-22 15:08:39.582 [INFO ] [runtime.busevents             ] - Circuit_C02 state updated to 1634.563
2016-10-22 15:08:55.582 [INFO ] [runtime.busevents             ] - Circuit_C02 state updated to 114.313
2016-10-22 15:09:11.583 [INFO ] [runtime.busevents             ] - Circuit_C02 state updated to 0.0
2016-10-22 15:09:27.584 [INFO ] [runtime.busevents             ] - Circuit_C02 state updated to 1767.75
2016-10-22 15:09:43.585 [INFO ] [runtime.busevents             ] - Circuit_C02 state updated to 0.0
2016-10-22 15:09:59.586 [INFO ] [runtime.busevents             ] - Circuit_C02 state updated to 474.188
2016-10-22 15:10:15.587 [INFO ] [runtime.busevents             ] - Circuit_C02 state updated to 1008.375
2016-10-22 15:10:31.588 [INFO ] [runtime.busevents             ] - Circuit_C02 state updated to 0.0
2016-10-22 15:10:47.588 [INFO ] [runtime.busevents             ] - Circuit_C02 state updated to 1422.375
2016-10-22 15:11:03.589 [INFO ] [runtime.busevents             ] - Circuit_C02 state updated to 38.688
2016-10-22 15:11:19.589 [INFO ] [runtime.busevents             ] - Circuit_C02 state updated to 0.0
2016-10-22 15:11:35.591 [INFO ] [runtime.busevents             ] - Circuit_C02 state updated to 1703.438
2016-10-22 15:11:51.581 [INFO ] [runtime.busevents             ] - Circuit_C02 state updated to 2126.313
2016-10-22 15:12:07.582 [INFO ] [runtime.busevents             ] - Circuit_C02 state updated to 2120.125
2016-10-22 15:12:23.583 [INFO ] [runtime.busevents             ] - Circuit_C02 state updated to 2121.938
2016-10-22 15:12:39.584 [INFO ] [runtime.busevents             ] - Circuit_C02 state updated to 2119.813
2016-10-22 15:12:55.584 [INFO ] [runtime.busevents             ] - Circuit_C02 state updated to 2114.25
2016-10-22 15:13:11.585 [INFO ] [runtime.busevents             ] - Circuit_C02 state updated to 2111.813
2016-10-22 15:13:27.586 [INFO ] [runtime.busevents             ] - Circuit_C02 state updated to 2112.688
2016-10-22 15:13:43.587 [INFO ] [runtime.busevents             ] - Circuit_C02 state updated to 2103.5
2016-10-22 15:13:59.588 [INFO ] [runtime.busevents             ] - Circuit_C02 state updated to 922.625
2016-10-22 15:14:15.589 [INFO ] [runtime.busevents             ] - Circuit_C02 state updated to 0.0
2016-10-22 15:14:31.589 [INFO ] [runtime.busevents             ] - Circuit_C02 state updated to 0.0

The 0.0s in the middle of the set are false since I know the pump is still on.


(Nathan Stratton) #12

It would be nice to add SMS notification when finished, in my family more the one person does the laundry so you would need to have the UI ask for a selection of a person to SMS when finished that work work just for the current cycle.


(Seaside) #13

I’m sending email notifications to a selection of people. I’m using mqtt to send notifications and then have mqttwarn sending the actual mail.
For me email is just as good as sms in terms of being a notifier. I know there are plenty of options in mqttwarn, not sure about sms though.

I guess a intelligent choice could be made depending on presence if you have that.

Regards s


(Nathan Stratton) #14

I have a system working, but I would love some help on how I could clean it up.

system.items

String    Notify_Message
String    Notify_Person

notify.rules

rule "Notify"
when
  Item Notify_Person received update
then  
  logInfo("Notify", "Notify: " + Notify_Person.state + " - " + Notify_Message.state
  if (Notify_Person.state == "nathan") {
    sendMail("832330xxxx@mms.att.net", "OpenHab", "" + Notify_Message.state)
  } else if (Notify_Person.state == "beth") {
    sendMail("832215xxxx@mms.att.net", "OpenHab", "" + Notify_Message.state)
  } else if (Notify_Person.sate == "joshua") {
    sendMail("304579xxxx@mms.att.net", "OpenHab", "" + Notify_Message.state)
end

Is this a good way of dealing with notifications? I figured that it puts it all in one place and lets all rules set Notify_Message and then Notify_Person. On a update it pushes the message out to the right person.

appliances.items

Switch    First_Washer                       "1st Floor Washer"                                       <washer>        (First_Laundry) 
String    First_Washer_Notify
Switch    First_Dryer                        "1st Floor Dryer"                                        <dryer>         (First_Laundry) 
String    First_Dryer_Notify

Switch    Second_Washer                      "2nd Floor Washer"                                       <washer>        (Second_Laundry) 
String    Second_Washer_Notify
Switch    Second_Dryer                       "2nd Floor Dryer"                                        <dryer>         (Second_Laundry) 
String    Second_Dryer_Notify

appliances.rules

rule "First Washer State Machine"
when
  Item Circuit_C14 changed
then
  if (First_Washer.state == OFF && Circuit_C14.state > 10) {
    sendCommand(First_Washer, ON)
  } else if (First_Washer.state == ON && Circuit_C14.state < 10) {
    sendCommand(First_Washer, OFF)
    if (First_Washer_Notify.state != "null") {
      // Notify person the Washer is finished
      postUpdate(Notify_Message, "1st Floor Washer Finished")
      postUpdate(Notify_Person, First_Washer_Notify.state)
    }
    // Clear Notify
    postUpdate(First_Washer_Notify, "null")
  }
end

rule "First Dryer State Machine"
when
  Item Circuit_C13 changed
then
  if (First_Dryer.state == OFF && Circuit_C13.state > 10) {
    sendCommand(First_Dryer, ON)
  } else if (First_Dryer.state == ON && Circuit_C13.state < 10) {
    sendCommand(First_Dryer, OFF)
    if (First_Dryer_Notify.state != "null") {
      // Notify person the Dryer is finished
      postUpdate(Notify_Message, "1st Floor Dryer Finished")
      postUpdate(Notify_Person, First_Dryer_Notify.state)
    }
    // Clear Notify
    postUpdate(First_Dryer_Notify, "null")
  }
end

rule "Second Washer State Machine"
when
  Item Circuit_C15 changed
then
  if (Second_Washer.state == OFF && Circuit_C15.state > 10) {
    sendCommand(Second_Washer, ON)
  } else if (Second_Washer.state == ON && Circuit_C15.state < 10) {
    sendCommand(Second_Washer, OFF)
    if (Second_Washer_Notify.state != "null") {
      // Notify person the Washer is finished
      postUpdate(Notify_Message, "2nd Floor Washer Finished")
      postUpdate(Notify_Person, Second_Washer_Notify.state)
    }
    // Clear Notify
    postUpdate(Second_Washer_Notify, "null")
  }
end

rule "Second Dryer State Machine"
when
  Item Circuit_C17 changed
then
  if (Second_Dryer.state == OFF && Circuit_C17.state > 10) {
    sendCommand(Second_Dryer, ON)
  } else if (Second_Dryer.state == ON && Circuit_C17.state < 10) {
    sendCommand(Second_Dryer, OFF)
    if (Second_Dryer_Notify.state != "null") {
      // Notify person the Dryer is finished
      postUpdate(Notify_Message, "2nd Floor Dryer Finished")
      postUpdate(Notify_Person, Second_Dryer_Notify.state)
    }
    // Clear Notify
    postUpdate(Second_Dryer_Notify, "null")
  }
end

I don’t really like the appliances.rules, lots of duplication, but the way it works is if and only if someone wants to be notified they go to the sitemap and select the person to notify for each device. As long as more then one event does not hit the notify.rules at once things should be ok.


(Stefan Zieren) #15

Thanks for the nice post!
You mentioned the Sonoff Pow Wifi Switch in the beginning. How can this be integrated with openhab? Is there a special binding available?
Thank you!


(SiHui) #16

(Hallo Ween) #17

I used the rule from the first post (the second one with delay), but i always get this error:

2016-10-25 12:48:45.971 [ERROR] [o.o.c.s.ScriptExecutionThread ] - Error during the execution of rule 'Washingmachine Consumption State Machine (Extended)': The name 'MODE_OFF' cannot be resolved to an item or type.

Do you know whats wrong?

I added the Washingmachine_OpState to my items-file like you described in your example and corrected the rule to my own item-names. Also i copied the text of the rule-file including all “import” “val” and “var” to my rule-file.

Is waschinmachine_opstate a string- or number-item? Is number-item right?


(Stefan Zieren) #18

Thanks


(Hallo Ween) #19

Ok, i found out what was wrong:

“Number” was missing on top of the rule-file. It should be this way:

val Number MODE_OFF = 0
val Number MODE_STANDBY = 1
val Number MODE_ACTIVE = 2
val Number MODE_FINISHED = 3

(Hallo Ween) #20

Please can you show me your rule-file?

I have to add some long timer also. Sometimes washing mashine needs delay for 5-10 minutes. And it would be better to do this with a timer instead of simple pause the rule.

Because if i stay in front of the washing machine when it´s finished very quick - rule will still be paused until delay is over. When i do it with timer, rule will see the restart of the washing machine for the next run immediately.


(Kjetil Asdal) #21

I am at work with no access to my rules at present. I’ll try to post something this evening.


( ) #22

Hello @sipvoip,
after you got the new item updating with the current state of whatever you are monitoring, you can use additional rules to trigger on events there and again execute some logic. That’s the real beauty of the automation how it is encouraged by openHAB. I’m sure you are fully aware of that, just wanted to state for others.

You posted your solution for SMS notification and that’s great. If you want to contribute it for others and are also looking for ideas on how to optimize it, it’s probably better you open a new thread :wink:

I’m btw using Pushover, which is a good alternative to SMS if you own a Smartphone.


( ) #23

I was thinking about that too! Did not implement yet but it’s also not really the focus of this thread. My idea was to receive one notification when the washing machine is done AND I’m at home and additionally to receive notifications when entering or leaving the apartment.


( ) #24

Thanks @sihui :wink:

The Sonoff Pow module is quite new and there was no firmware available yet. However, I contacted arendt, the developer of the Sonoff alternative firmware and he was amazingly quick and professional in adding support for the Sonoff Pow:

@hipohop If you are interested in the Pow and are not afraid to do what was described in the article linked by sihui, it’s a pretty good choice to get your consumption measurement started :wink:

Update: I just remembered, that this could be of interest to @TommySharp. Check here for more details.


( ) #25

Hello, nice you got it working. Are you on openHAB 1.8? The Datatype can be omitted in OH2 but I can add it to the example to make this Tutorial valid for OH1.8 as well.


(alex_alexandroff22) #26

Hi Thom,

please add an example for OH 1.8
Thx!


( ) #27

My 10 seconds do not create that kind of problem but I can see how 10 minutes could spoil the fun. Are you sure that you chose the right thresholds? I found that my washing machine uses slightly more power in the idle-active phases than in the real idle phase.


( ) #28

Sounds like you should invest in a second measurement module :wink:


(Hallo Ween) #29

I´m on openhab 1.8.3. With the adding of “Number” now it works.

I will make another test when my wife is using the washing machine next time.

Little bit offtopic:
I saw the sonoff pow. How accurate is the power measurement? And how can i flash it? Do i have to use some extra equipment or is it done with mini usb cable?

Is there a sonoff for measuring 3 phases too? So i could see the power consumption of my whole house?


( ) #30

Great. I’ll update the first post. @alex_alexandroff22 now you know :wink:

Regarding Sonoff: It was just released and everyone involved is still waiting for the shipment from china to arrive, probably in around one week on my side. I’m actually more interested in the relative change in consumption more than in the accuracy of the reading… For all other details, please see the link posted by @sihui