Washing machine status widget

Hi Jonathan

thx - that helps a lot. How du you calculate your runtime?

Thats what I have so far but I think it will not work and if it would somehow work, it would not reset to 0

configuration: {}
triggers:
  - id: "1"
    configuration:
      cronExpression: 0 * * * * ? *
    type: timer.GenericCronTrigger
conditions:
  - inputs: {}
    id: "3"
    configuration:
      itemName: WashingMachine_OpState
      state: "2"
      operator: =
    type: core.ItemStateCondition
actions:
  - inputs: {}
    id: "2"
    configuration:
      type: application/javascript;version=ECMAScript-2021
      script: |+
        WashingMachine_Runtime.state + 1

    type: script.ScriptAction

Thank you
Daniel

Hi Daniel,

your cron expression should be triggered once a minute, is this the case? Then I think your rule should work!

To reset to 0 you could add a second rule that gets triggered once when the status changes to RUNNING.

Regards
Thomas

I am resetting my timer (to 1 min, just like Thomas stated elsewhere) when the state machine switches to the running state:

if (Waschmaschine_OpState.state != MODE_ACTIVE) {
            Waschmaschine_OpState.postUpdate(MODE_ACTIVE)
            Waschmaschine_Runtime.postUpdate(1)
          }

Cheers
Jonathan

thank you jonathan

can you please send the whole rule, as this seems only to be a part of the rule.

Thank
Daniel

thank you - I oversaw your post in the first place.

Will try it in combination with the suggestion of Jonathan

Sure:


configuration: {}
triggers:
  - id: "1"
    configuration:
      itemName: SteckdoseWaschmaschine_Power
    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

        val String logPrefix = 'Waschmaschine StateMachine - '


        if (EnableLog_WaschmaschineRules.state == ON) logInfo('waschmaschine.rules', logPrefix + 'StateMachine Zustand alt: ' + Waschmaschine_OpState.state.toString + '; Leistung momentan: '+ SteckdoseWaschmaschine_Power.state.toString)

        if (EnableLog_WaschmaschineRules.state == ON) logInfo('waschmaschine.rules', logPrefix + 'Leistung momentan (doubleValue): '+ (SteckdoseWaschmaschine_Power.state as QuantityType<Power>).doubleValue.toString)


        if ((SteckdoseWaschmaschine_Power.state as QuantityType<Power>).doubleValue < 0.5) {
          Waschmaschine_OpState.postUpdate(MODE_OFF)
        }

        else if ((SteckdoseWaschmaschine_Power.state as QuantityType<Power>).doubleValue > 15) {
          if (Waschmaschine_OpState.state != MODE_ACTIVE) {
            Waschmaschine_OpState.postUpdate(MODE_ACTIVE)
            Waschmaschine_Runtime.postUpdate(1)
          }
        }

        else if ((SteckdoseWaschmaschine_Power.state as QuantityType<Power>).doubleValue < 6.5) {
            if (Waschmaschine_OpState.state == MODE_OFF) Waschmaschine_OpState.postUpdate(MODE_STANDBY)
            else if (Waschmaschine_OpState.state == MODE_ACTIVE) Waschmaschine_OpState.postUpdate(MODE_FINISHED)
        }

        if (EnableLog_WaschmaschineRules.state == ON) logInfo('waschmaschine.rules', logPrefix + 'StateMachine Zustand neu: ' + Waschmaschine_OpState.state.toString)
    type: script.ScriptAction

Edit:
This rule design is based on: Washing Machine State Machine - Tutorials & Examples - openHAB Community

Cheers
Jonathan

2 Likes

thank you

Hey Rondal,

i hope you’ve got an advice for me…

All my Miele Maschines doesn’t update the states for the widget…

The Dryer for example looks like:

component: widget:washing_machine_v4
config:
  title: Trockner
  state: =items.Trockner_OperationState.state
  runtime: =(items.Trockner_ProgramRemainingTime.state)/60
  header: =items.Trockner_ProgramPhase.state
  footer: =items.Trockner_ActiveProgram.state + ' / ' + items.Trockner_DryingTarget.state
  dryer: ON

On a created Sitemap all Points are updated correctly (automatically) and show the correct state.

But in the widget it doesn’t work - state is always “-”

Have you any idea for me?

Installation error

Hi there,

I’m getting an error trying to install this widget from Marketplace.

[ERROR] [mmunity.CommunityUIWidgetAddonHandler] - Unable to parse YAML: Cannot deserialize value of type `java.util.Date` from String "Oct 2, 2021, 9:24:59 PM": not a valid representation (error: Failed to parse Date value 'Oct 2, 2021, 9:24:59 PM': Unparseable date: "Oct 2, 2021, 9:24:59 PM")
 at [Source: (StringReader); line: 36, column: 12] (through reference chain: org.openhab.core.ui.components.RootUIComponent["timestamp"])
[ERROR] [mmunity.CommunityUIWidgetAddonHandler] - Widget from marketplace is invalid: Unable to parse YAML

Any idea why and how to solve this?

I haven’t installed it from the marketplace myself so I cannot really help here. Which OH version are you using? It seemed to work for quite a few other users so this may have something to do with a new OH version maybe?

It’s openHAB 3.2 Release running on Ubuntu Linux.

Any hint why “… _Remainingprogramtime” is ony showed as NaN? In my Setup the String is for example “3000 s” the other part work fine…

Not sure - is the item type 'Number:Type’ for _Remainingprogramtime?

Just a thought for people who have a washdryer combo: Would it be possible to introduce another state “DRYING” (next to OFF, RUNNING or FINISHED) and then automatically switch Dryer Mode to ON?

Good idea. But you should be able to do this without any changes to the widget: just use an expression for the dryer mode configuration and you should be fine :slight_smile:

Currently I have:

component: widget:washing_machine_v4
config:
  title: LG WashDryer
  state: =MQTTThinQ_WashDryerState.state
  runtime: =openHAB2_ItemThinqRemainingminutes.state
  dryer: =openHAB2_ItemThinqDrying.state

openHAB2_ItemThinqDrying is a switch but unfortunately it doesn’t work… Does it need to be a string?

Unfortunately it has to be a string yes. This is because I only use this as a static configuration without an item at all. You could remove the string literals in the widget code where checks for the dryer mode are implemented or use an expression that evaluates to a string based on your switch item.

I changed everything to String now but it seems it doesn’t read the state correctly… Also a .toString() at the end didn’t help… I will look at the widget source - maybe I can track down the problem…

You should use: items.openHAB2_ItemThinqDrying.state

It should work then I guess

Arg… I always do the same mistake! Thanks! :slight_smile: