Washing Machine State Machine

power
Tags: #<Tag:0x00007fe0630314e8>

(martijn) #163

Sorry…
This one I have bought 5 years ago… still working properly using a USB stick and 2 ‘plugs’
There is also a binding available. you can measure and switch on/off.
https://www.plugwise.com/en_US/products/plug

I read somewhere this also can be done by sonoff (Chinese stuff).


(Linus) #166

I like that tutorial a lot, unfortunately I’m not getting the expected results. I’m new at this which is why I suppose I’m making a beginners mistake. The only output I receive in my GUI is a “-”.

washingmachine.items:

String Washingmachine_OpState “Washingmachine State [MAP(washingmachine.map):%s]”

washingmachine.rules:

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 avmfritz_FRITZ_DECT_200_1_087610044241_power changed
then
if (avmfritz_FRITZ_DECT_200_1_087610044241_power.state < 0.2) Washingmachine_OpState.postUpdate(MODE_OFF)
else if (avmfritz_FRITZ_DECT_200_1_087610044241_power.state > 10) Washingmachine_OpState.postUpdate(MODE_ACTIVE)
else if (avmfritz_FRITZ_DECT_200_1_087610044241_power.state < 3) {
if (Washingmachine_OpState.state == MODE_OFF) Washingmachine_OpState.postUpdate(MODE_STANDBY)
else if (Washingmachine_OpState.state == MODE_ACTIVE) Washingmachine_OpState.postUpdate(MODE_FINISHED)
}
end

default.sitemap entry, embedded in a frame:

Text item=Washingmachine_OpState label=“Waschmaschine [MAP(washingmachine.map):%d]” icon=“washingmachine_2”

washingmachine.map:

0=Aus
1=Standby
2=Aktiv
3=Fertig
NULL=?
-=-

Some example lines from my measurements:

2019-02-10 15:58:39.185 [vent.ItemStateChangedEvent] - avmfritz_FRITZ_DECT_200_1_087610044241_power changed from 394.390 W to 389.310 W
2019-02-10 15:58:54.815 [vent.ItemStateChangedEvent] - avmfritz_FRITZ_DECT_200_1_087610044241_power changed from 389.310 W to 15.300 W
2019-02-10 15:59:09.967 [vent.ItemStateChangedEvent] - avmfritz_FRITZ_DECT_200_1_087610044241_power changed from 15.300 W to 15.230 W
2019-02-10 15:59:24.975 [vent.ItemStateChangedEvent] - avmfritz_FRITZ_DECT_200_1_087610044241_power changed from 15.230 W to 15.300 W
2019-02-10 15:59:39.805 [vent.ItemStateChangedEvent] - avmfritz_FRITZ_DECT_200_1_087610044241_power changed from 15.300 W to 15.230 W
2019-02-10 15:59:54.821 [vent.ItemStateChangedEvent] - avmfritz_FRITZ_DECT_200_1_087610044241_power changed from 15.230 W to 15.660 W
2019-02-10 16:00:10.474 [vent.ItemStateChangedEvent] - avmfritz_FRITZ_DECT_200_1_087610044241_power changed from 15.660 W to 3.140 W
2019-02-10 16:00:24.803 [vent.ItemStateChangedEvent] - avmfritz_FRITZ_DECT_200_1_087610044241_power changed from 3.140 W to 3.360 W
2019-02-10 16:00:54.825 [vent.ItemStateChangedEvent] - avmfritz_FRITZ_DECT_200_1_087610044241_power changed from 3.360 W to 3.070 W
2019-02-10 16:01:25.005 [vent.ItemStateChangedEvent] - avmfritz_FRITZ_DECT_200_1_087610044241_power changed from 3.070 W to 3.360 W
2019-02-10 16:01:39.833 [vent.ItemStateChangedEvent] - avmfritz_FRITZ_DECT_200_1_087610044241_power changed from 3.360 W to 3.140 W
2019-02-10 16:01:54.927 [vent.ItemStateChangedEvent] - avmfritz_FRITZ_DECT_200_1_087610044241_power changed from 3.140 W to 14.730 W
2019-02-10 16:02:10.041 [vent.ItemStateChangedEvent] - avmfritz_FRITZ_DECT_200_1_087610044241_power changed from 14.730 W to 3.430 W
2019-02-10 16:02:24.927 [vent.ItemStateChangedEvent] - avmfritz_FRITZ_DECT_200_1_087610044241_power changed from 3.430 W to 3.070 W
2019-02-10 16:02:54.887 [vent.ItemStateChangedEvent] - avmfritz_FRITZ_DECT_200_1_087610044241_power changed from 3.070 W to 3.360 W
2019-02-10 16:03:24.864 [vent.ItemStateChangedEvent] - avmfritz_FRITZ_DECT_200_1_087610044241_power changed from 3.360 W to 3.070 W
2019-02-10 16:03:54.877 [vent.ItemStateChangedEvent] - avmfritz_FRITZ_DECT_200_1_087610044241_power changed from 3.070 W to 2.930 W
2019-02-10 16:04:09.840 [vent.ItemStateChangedEvent] - avmfritz_FRITZ_DECT_200_1_087610044241_power changed from 2.930 W to 2.640 W
2019-02-10 16:04:39.825 [vent.ItemStateChangedEvent] - avmfritz_FRITZ_DECT_200_1_087610044241_power changed from 2.640 W to 2.930 W
2019-02-10 16:04:55.208 [vent.ItemStateChangedEvent] - avmfritz_FRITZ_DECT_200_1_087610044241_power changed from 2.930 W to 2.640 W
2019-02-10 16:05:24.834 [vent.ItemStateChangedEvent] - avmfritz_FRITZ_DECT_200_1_087610044241_power changed from 2.640 W to 2.930 W

Basic UI Output:
BasicUI-Output

May somebody please help me to find the problem?


(Tom) #167

You are defining the mapping in both your .items and your .sitemap. Also, in your .sitemap you are using a %d which is for a number, you have the correct %s in your .items definition.


(Linus) #168

Thank you very much. It’s working fine now, but I still get the following warning in the logs:

17:13:41.396 [WARN ] [.rest.core.item.EnrichedItemDTOMapper] - Failed transforming the state ‘0’ on item ‘Washingmachine_OpState’ with pattern ‘MAP(AVM.map):%d’: Cannot format state ‘0’ to format ‘%d’

It says “Cannot format state”, but still the “0” gets transformed into “Aus” as expected and described in my AVM.map file:

0=Aus
1=Standby
2=Active
3=Fertig
-=-
NULL=-

The result in the Basic UI is as expected:
image

For completeness, this is how my item looks like:

Number Washingmachine_OpState “Washingmachine State [MAP(AVM.map):%d]”

What am I doing wrong and how to avoid that warning?


(Udo Hartmann) #169

You have to use %s instead.

Number Washingmachine_OpState “Washingmachine State [MAP(AVM.map):%s]”