Washing Machine State Machine

And you can more easily use a generic .map file to translate a state into something more human-readable. (WAF) If you use numbers, you can only have one set per file. Otherwise you could combine several in one.

However…

If you use numbers for the state, you can use dynamic icons. For example in openHAB2 you can use the default <washingmachine_2> icon, that has variants for 0, 1, 2, and 3.

0 = no light (OFF?)
1 = green light (FINISHED?)
2 = red light (ACTIVE?)
3 = yellow light (STANDBY?)

@ThomDietrich Looking at those icons, the values do not match your states, am I right? If so, you could perhaps change mapping of the states to match the default icon set? In that case the item definition in the tutorial could change to

Number Washingmachine_OpState "Washingmachine State [%d]" <washingmachine_2>

Good idea. I am using a different washing machine icon and it doesn’t exist in different version. So this doesn’t really matter to me. I would like that feature of course.

Something I would need to test: Does @rlkoshak’s solution not work with the following?

  • washingmachine_off.svg
  • washingmachine_finished.svg

Btw. I just realized, that my mapping file is not part of the first posting. Nobody said something, I should add it to make the tutorial complete.

It did for me as of a month or so ago. I’ve not rebuilt my sitemap yet to know if something is broken (and I might go with Habpanel this time…

The usual caveats apply:

  • must have a default icon
  • the state part of the icon name must be all lower case
  • the icon selected is what the state gets mapped to in the label, not the Item’s raw state (this is a change from how it worked in OH 1, I haven’t decided yet whether I just dislike that or really hate it, I just don’t find it intuitive)

Okay so yes that would work @rtvb

@rlkoshak Could you add this information and an example to the currently open PullRequest on items? (Sorry I didn’t comment on that one yet…)

I hate it and actually think the change is a design flaw. If you use a mapping to localize labels (like Dutch in my case) this would force me to create custom icons, or, actually for any other language. This is too much to ask from the mass. Changing label mappings (or having multi language sitemaps for one single items file) would imply having multiple icon sets. A no-go for me.

1 Like

I thought it was there. Going to add it if I somehow didn’t make these clear.

Looks like the info was there but not clear. I reworked the section hopefully making it more clear.

I did some additional testing. It looks like classic UI does use the “unmapped” value (like OH1), basic UI does too (but doesn’t auto-refresh) but the iOS app NOT use the unmapped value.

It doesn’t matter if the icon is remapped in the sitemap.

test.items

Group Test

Switch Test1 "Schakelaar 1 [MAP(nl.map):%s]" <switch> (Test)
Switch Test2 "Schakelaar 2 [%s]" <switch> (Test)

test.sitemap

sitemap test label="Test" {
	Frame label="Schakelaars" {
		Switch item=Test1
		Text item=Test1
		Text item=Test1 label="Schakelaar 1 [%s]" icon="switch"

		Switch item=Test2
		Text item=Test2
		Text item=Test2 label="Schakelaar 2 [MAP(nl.map):%s]" icon="switch"

		Group item=Test
	}
}

nl.map

ON=AAN
OFF=UIT

I agree, that is probably the most convincing use case for BasicUI to use the raw Item state, not the mapped Item state.

Too bad at our house we all mostly use an iPhone or iPad with native app to control OH.

Known bug

My Sonoff Pow (or my Washing Machine, or my Dryer?) detects some peaks, even if the program is finished. Partly because they machine perfome some “anti-crease” actions to prevent the laundry to get knitted. partly because of some internal measuring effects of the Pow.

So I came up with an different approach for detecting the machine states: If you’re using persistance, why not use historic data for this. So I use the item.averageSince(AbstractInstant) extension to get an average of the last minutes to check, if there’s just noise or if it’s really a change of state:

so my rule ended up like this:

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

rule "Washingmachine Consumption State Machine"
when
    Item Washingmachine_Power changed
then
    if (Washingmachine_Power.averageSince(now.minusMinutes(2)) < 0.2) Washingmachine_OpState.postUpdate(MODE_OFF)
    else if (Washingmachine_Power.averageSince(now.minusMinutes(2))> 10) Washingmachine_OpState.postUpdate(MODE_ACTIVE)
    else if (Washingmachine_Power.averageSince(now.minusMinutes(2))< 5) {
        if (Washingmachine_OpState.state == MODE_OFF) Washingmachine_OpState.postUpdate(MODE_STANDBY)
        else if (Washingmachine_OpState.state == MODE_ACTIVE) Washingmachine_OpState.postUpdate(MODE_FINISHED)
    }
end
3 Likes

Also just an idea for making sure, the washing machine gets depleted: just attaching a button at the washing machine, which is pressed, if you take out the clothes. I’m thinking of Amazon Dash Button:
http://docs.openhab.org/addons/bindings/amazondashbutton/readme.html

In that case, adding a item “Washingmachine_full” would be ON the same time, Washingmachine_OpState goes over to “MODE_FINISHED”. So you can add a rule, if the state of Washingmachine_full is ON since 30mins or so, you get some more decisive action like some creepy sound playing in the house, or whatever you like. That’s our pain even getting some pushovers to your mobile when the machine is ready: you press OK and it’s easily forgotten.

1 Like

Hey Thomas, averageSince is a nice idea! I had my personal reasons to not relying on persistence here but I can totally see the benefit, even for my system now. I’ll add the solution to the first post.
I’ll add the button idea as well. I myself just use the machine for it by only turning it off after I’ve removed everything. You know how it is, “Tausend Wege führen nach Rom” :slight_smile:

I’ve no time right now, please remind me if I forget :wink: Thanks!

I hope to try some of this this weekend. But curious how effective identifying your power consumption state on smaller appliances like toasters is. Or if there are multiple appliances going at the same time, if OH2 is getting confused on reporting the correct state of each.

I’m also considering getting an Aeotec HEM. Would monitoring the power consumption there give a better measurement?

Basically, I’m pretty sure, you’re not getting a clear picture, if there’s are more than one device on one measurment device. There’s too much noise to be considered and the logic would be a total mess. I didn’t expect much from my 10€ China-device, but it seems pretty stable. If you have a dedicated measuring device of any kind, you have to find out two things:

  1. how is the power consumption regarding to what you would like to achieve
  2. how short your intervals schould be. I can imagine a toaster requires a much shorter interval than a washing machine.

If you have done this (like @ThomDietrich explained in the first post of this thread), you can then adjust your rule to that.
Long Story short: I don’t think there’s a device small enough to be monitored and it is nearly impossible to filter a specific device, if you connect more than one to your power measurement device.

as explained above, the 10€ China-device delivers enough output for a clear rule. I don’t know the Aeotec HEM, but it should do the job. All you need is a reading of the wattage over time and then compare it to your thresholds - that’s it.

I do have some headaches also regarding the amount of data, which goes into the MySQL Server at this point. But I’m thinking of a garbage collection within MySQL or in a monthly/weekly rule within OH2 to get the old data out of the persistance. There are some values, which I want to persist over years (e.g. some variables regarding heating, weather and so on), to have a base for future rules or comparisons - but I don’t think the persisted Washing Machine states will needed for this! :wink:

@ptmuldoon I agree, it would be a fun experiment to break down overall consumption of multiple devices but from a practical standpoint, just get two modules and be done with it :wink:

Regarding the toaster: First it’s not a problem to detect states as long as they are characterized by a certain wattage (and/or duration). @binderth is right that it could be problematic to observe the toaster, as he will be active only for a short time. However you (@binderth) forgot, that most modules have a threshold option :wink: They will send acyclic extra measurements if a certain value is passed.
Both the mentioned Homematic and Sonoff Pow module provide this functionality.

I’d also recommend the Sonoff Pow as a cheap good module:

1 Like

Ok, but I’m really not sure how I connect those cheap modules to a washing machine or other without needing splice the power plug to the device, etc. Unless I am misreading the instructions to use them.

Aeotec offers the more expensive zwave home energy meter. And I was thinking perhaps monitoring the usage there of each device and you could do the same thing?

https://www.amazon.com/Aeon-Labs-ZW095--Z-Wave-Energy/dp/B00XD8WZX6/ref=as_li_ss_tl?ie=UTF8&qid=1466603467&sr=8-1&keywords=Home+Energy+Meter+gen5&linkCode=sl1&tag=sso0e-20&linkId=36f039c97d7d590b86731fd95b59a04d

1 Like

I have one of those hooked up to the main feed circuit in the fuse box, so basically monitoring the total energy consumption of my house. It is working very well, and seems to give fairly precise measurement reports.

For monitoring of individual appliances, however, I am using Fibaro Wall Plugs (FGWPF-101). These devices are very well suited for the purpose. I am currently using these on my washing machine, drying machine, dishwasher, freezer and water heater.

Apart from being very nice devices, that are rock solid in operation, I can see the following two benefits:

  • Ease of use - simply plug it into the socket, and then plug your appliance into the device.
  • Master switch - If you happen to leave for an extended vacation, and forgot to turn off your washing machine, you can simply cut all power to the unit, :slight_smile:
2 Likes

oh. I didn’t understand this on my first readovers, but now I’m getting a bit more context. So this means basically, that the Sonoff sends (regardless of the intervall set in TelePeriod) a MQTT message, if I set a low and high wattage threshold and this threshold is met?

PowerHigh       | <watt>  | Set power high threshold value
PowerLow        | <watt>  | Set power low threshold value

I’m getting some more ideas! :wink: