Washing machine status widget

Same on android beta

I assume you installed this through the marketplace? Could you try to add this widget manually in the Dev Tools and see if it looks strange there as well?

same problem, in fact, all the design chnage between chrome and the android app is strange

chrome:

App android

obviously is not your widget :slight_smile:

Ok let me know if you find something related to my widget :+1:

You might want to consider opening another issue for your problem to find someone who is able to help.

yes, thanks !

Hi Thomas,

Thank you for those awesome widgets youā€™ve createdā€¦
Currently iā€™m moving from my old files based Setup to MainUI only and iā€™m struggling a bit on how to set the items,scripts and rulesā€¦

So far i have setup my wallplug item with the energy consumption and the washing_machine_state / -runtime itemsā€¦

Iā€™d Like to use this rule since it makes it easier to get washingmachine,dryer,dishwasher items/widgets setupā€¦

Now iā€™m a bit confused which scripts/rules do i needā€¦ And where to put Themaā€¦ And would like to ask if you could share some more details on your current multi item rulesetupā€¦

Thanks

Hi Holger,

I agree it can get a bit confusing at timesā€¦

Youā€™ll need two rules in total and your item names must meet some requirements:

  1. Rule to determine the current status of your device (see rule I shared a couple of posts before this one). This rule should be triggered whenever one of the outlets consumption values changes.
  2. Rule to determine the time since the last status change (see step 3 in other post above: Washing machine status widget - #3 by DrRSatzteil). This should be fired every minute as long as the device is in RUNNING state. I still have this rule three times separately for every deviceā€¦

Item name requirements:
Since the energy consumption profile of my devices (dishwasher, dryer and washing machine) differs every device must be configured differently. To do so I created a couple of items that also allow me to easily tweak the rule if something is not working as expected. Rule 1. relies on some conventions to find the corresponding items:

  1. Your outlet must be modelled as equipment in the semantic model. The triggering item must be a Point of this equipment.
  2. Your washing machine must be represented by a group (ideally but not necessarily part of the semantic model) thatā€™s named as the outlet without a leading string ā€žoutlet_ā€œ (e.g. washing and outlet_washing)
  3. The config items need to be members of a group named exactly like your washing machine group equipment with a ā€ž_configā€œ suffix (e.g. washing and washing_config). This group must be a member of the washing group in this example.
  4. The config group must contain three items with the following names (following the ā€žwashingā€œ example)
    a) washing_config_threshold: Actually not a good name: this Number Item value sets the expected energy consumption when the washing machine is finished. Whenever the consumption changes to a value below this value we start a timer with the time configured in c). If the value doesnā€™t go above this threshold while we wait we assume that the washing is finished. Especially washing machines sometimes do almost nothing for a couple of minutes which can easily lead to false positives.
    b) washing_config_zero: Number Item that determines when your machine is considered to be off (should ideally be 0 if your device does not consume standby power)
    c) washing_config_waittime: Number Item that was already explained in a). Configures the time we wait until we assume that the washing is really finished and was not just having a little break.
    d) washing_config_icon: This string item is optional and represents the name of the icon that will be used in the notification message. Defaults to ā€žwhitegoodā€œ.

Donā€™t forget to enable persistence for all of these or otherwise you will lose your settings during reboot.

Iā€˜m pretty sure I forgot something but this should get you started anyway. Feel free to ask if you need any more assistance.

1 Like

Can anybody help me with formatting a number?


gives me
image
Iā€™d like to display integers, like ā€œ35 Wattā€. Can anybody help me formatting the header string?

Metadata / State description wonā€™t help

Try state.split(ā€œ.ā€œ)[0] + ā€œ Wattā€œ

If you want to use the state description you need to use displayState instead of state.

THX! displayState worked perfectly.

Wonderful widget, by the way!

hello, iā€™m in trouble with this ruleā€¦when i run it it gives me many errors:

2022-02-07 16:06:49.052 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'd3264944b9' failed: var logger =  ___ Java.type("org.slf4j.LoggerFactory").getLogger("scripts.washing.runtime");
var PersistenceExtensions = Java.type("org.openhab.core.persistence.extensions.PersistenceExtensions");
var ZonedDateTime = Java.type("java.time.ZonedDateTime");
var Duration = Java.type("java.time.Duration");
var lastUpdate = PersistenceExtensions.lastUpdate(ir.getItem('Asciugatrice_kWhMinuto'), "mapdb");
logger.info('Status della asciugatrice cambiato alle ' + lastUpdate);
var minutesSinceLastUpdate = Duration.between(lastUpdate, ZonedDateTime.now()).toMinutes();
logger.info('Status della asciugatrice cambiato ' + minutesSinceLastUpdate + ' minuti fa');
events.postUpdate('Asciugatrice_Runtime', minutesSinceLastUpdate);
   1. The method or field Java is undefined; line 1, column 13, length 4
   2. The method or field Java is undefined; line 2, column 116, length 4
   3. The method or field Java is undefined; line 3, column 212, length 4
   4. The method or field Java is undefined; line 4, column 265, length 4
   5. The method or field ir is undefined; line 5, column 348, length 2
   6. The method or field events is undefined; line 9, column 650, length 6

can you help me on whatā€™s wrong?
this is my entire rule code:

configuration: {}
triggers:
  - id: "2"
    configuration:
      cronExpression: 0 * * * * ? *
    type: timer.GenericCronTrigger
conditions:
  - inputs: {}
    id: "3"
    configuration:
      itemName: Asciugatrice_OpState
      state: "2"
      operator: =
    type: core.ItemStateCondition
actions:
  - inputs: {}
    id: "1"
    configuration:
      type: application/vnd.openhab.dsl.rule
      script: >-
      
        var logger = Java.type("org.slf4j.LoggerFactory").getLogger("scripts.washing.runtime");

        var PersistenceExtensions = Java.type("org.openhab.core.persistence.extensions.PersistenceExtensions");
        var ZonedDateTime = Java.type("java.time.ZonedDateTime");
        var Duration = Java.type("java.time.Duration");

        var lastUpdate = PersistenceExtensions.lastUpdate(ir.getItem('Asciugatrice_kWhMinuto'), "mapdb");
        logger.info('Status della asciugatrice cambiato alle ' + lastUpdate);
        var minutesSinceLastUpdate = Duration.between(lastUpdate, ZonedDateTime.now()).toMinutes();
        logger.info('Status della asciugatrice cambiato ' + minutesSinceLastUpdate + ' minuti fa');

        events.postUpdate('Asciugatrice_Runtime', minutesSinceLastUpdate);
    type: script.ScriptAction

widgets seems to work perfectly but remaining time is not working, keep displaying NaaN:NaaN, but animations works.
widget config is this one:

whatā€™s wrong?

You need to create an ECMA JavaScript rule and paste the code there. You created a DSL rule. This should fix your problems :+1:

OMGā€¦crazy for this. ok iā€™ve changed it, i will check that everything else is okay.
thanks a lot for this hint!

iā€™ve set it to ECMAScript (ECMA - 262 Edition 5.1) and in log i have no more errors, but in the widget, i have the running minute counter that start from 0:00 and count till 0:04 and then reset to 0:00.
some other times, count till 0:01 and then back to 0:00 and other times, til 0:02 and back to 0:00.
any idea?

It might be that your configuration items need some fine tuning: what are your waittime and threshold parameters? It seems that your machine consumes less than the threshold for a short period and your waittime is even lower than this period.

this is the rule to get the status of the dryer:

configuration: {}
triggers:
  - id: "1"
    configuration:
      itemName: Asciugatrice_kWhMinuto
    type: core.ItemStateChangeTrigger
conditions: []
actions:
  - inputs: {}
    id: "2"
    configuration:
      type: application/vnd.openhab.dsl.rule
      script: >-
        val Number MODE_OFF = 0

        val Number MODE_STANDBY = 1

        val Number MODE_ACTIVE = 2

        val Number MODE_FINISHED = 3

        logInfo("Asciugatrice Status","Regola in esecuzione")
          
        if (Asciugatrice_kWhMinuto.state < 0.001 | kWh) {
           Asciugatrice_OpState.postUpdate(MODE_OFF) 
           logInfo("Asciugatrice Status","Asciugatrice SPENTA")

           
        } else if (Asciugatrice_kWhMinuto.state > 0.300 | kWh) {
            Asciugatrice_OpState.postUpdate(MODE_ACTIVE)
            logInfo("Asciugatrice Status","Asciugatrice IN ASCIUGATURA")

            
        } else if (Asciugatrice_kWhMinuto.state < 0.100 | kWh) {
            Asciugatrice_OpState.postUpdate(MODE_STANDBY)
            logInfo("Asciugatrice Status","Asciugatrice in STANDBY (Status "+Asciugatrice_OpState.state+")")

        } else if (Asciugatrice_kWhMinuto.state < 0.003 | kWh) {
            Asciugatrice_OpState.postUpdate(MODE_FINISHED)
            logInfo("Asciugatrice Status","Asciugatrice ha FINITO (Status "+Asciugatrice_OpState.state+")")
            }
    type: script.ScriptAction

and this is the rule to get the running time:

configuration: {}
triggers:
  - id: "2"
    configuration:
      cronExpression: 0 * * * * ? *
    type: timer.GenericCronTrigger
conditions:
  - inputs: {}
    id: "3"
    configuration:
      itemName: Asciugatrice_OpState
      state: "2"
      operator: =
    type: core.ItemStateCondition
actions:
  - inputs: {}
    id: "1"
    configuration:
      type: application/javascript
      script: >-
        var logger =
        Java.type("org.slf4j.LoggerFactory").getLogger("scripts.washing.runtime");

        var PersistenceExtensions = Java.type("org.openhab.core.persistence.extensions.PersistenceExtensions");

        var ZonedDateTime = Java.type("java.time.ZonedDateTime");

        var Duration = Java.type("java.time.Duration");

        var lastUpdate = PersistenceExtensions.lastUpdate(ir.getItem('Asciugatrice_kWhMinuto'), "mapdb");

        logger.info('Status della asciugatrice cambiato alle ' + lastUpdate);

        var minutesSinceLastUpdate = Duration.between(lastUpdate, ZonedDateTime.now()).toMinutes();

        logger.info('Status della asciugatrice cambiato ' + minutesSinceLastUpdate + ' minuti fa');

        events.postUpdate('Asciugatrice_Runtime', minutesSinceLastUpdate);
    type: script.ScriptAction

i also have ā€œscripts.washing.runtimeā€ for 3 different rules. do i have to rename this to avoid any conflict?
also for this second rule, i donā€™t get any log info when runsā€¦