Introducing: Automated Tests for my openHAB

I have upgraded vom 3.1 to 3.4m3 and I lost a roborock, I lost echo-Control, the doorbird is not working… and maybe more… so to make finding easier, why not have a rule that I can trigger in a room that tests everything in this room and I just watch things move, turn on , react?
Sounds simple, but it took me 4 years to realize that this is missing in my setup :slight_smile:

so here is my first simple rule for my living room.
Animation

That is build with a script, an item and a page-thingy-column-cell

Script:

events.postUpdate("Wohnzimmer_Tests", "starte tests")

var Tests = [];
//Tests.push('Echo');
//Tests.push('Rollladen');
Tests.push('Sichtschutz');

Tests.forEach(function (test_to_run) {
  if(test_to_run == 'Echo'){    
    events.postUpdate("Wohnzimmer_Tests", "teste Amazon Echo")
    var echo_test_nachricht = '<speak><audio src="soundbank://soundlibrary/home/amzn_sfx_doorbell_chime_01"/>' +
              '<say-as interpret-as="interjection">Test</say-as>' +
              '<break time="100ms"/>'+
              '<say-as interpret-as="interjection">1 2 3</say-as>'+
              '</speak>';
    events.sendCommand("Wohnzimmer_Echo_Sprich",echo_test_nachricht)
  };
  
  if(test_to_run == 'Rollladen'){    
    var Rollladen = [];
    Rollladen.push("WohnzimmerFensterHintenRollladen_Position");
    Rollladen.push("WohnzimmerFensterMitteRollladen_Position");
    Rollladen.push("WohnzimmerFensterVorneRollladen_Position");

    Rollladen.forEach(function (value) {
      events.postUpdate("Wohnzimmer_Tests", "teste Rollladen" + value )
      var position_before_testing = itemRegistry.getItem( value ).getState()
      events.sendCommand(value,"0")
       java.lang.Thread.sleep(3000)
      events.sendCommand(value,"100")
       java.lang.Thread.sleep(3000)
      events.sendCommand(value,position_before_testing)
    });
  };

  if(test_to_run == 'Sichtschutz'){    
    var Sichtschutz = [];
    Sichtschutz.push("WohnzimmerFensterHintenSichtschutz_Position");
    Sichtschutz.push("WohnzimmerFensterVorneSichtschutz_Position");

    Sichtschutz.forEach(function (value) {
    events.postUpdate("Wohnzimmer_Tests", "teste Sichtschutz" + value)
      var position_before_testing = itemRegistry.getItem( value ).getState()
      events.sendCommand(value,"0")
       java.lang.Thread.sleep(3000)
      events.sendCommand(value,"100")
       java.lang.Thread.sleep(3000)
      events.sendCommand(value,position_before_testing)
    });
  };
});

events.postUpdate("Wohnzimmer_Tests", "Test beendet")
java.lang.Thread.sleep(3000)
events.postUpdate("Wohnzimmer_Tests", "") //status is cleared, test is not running anymore.

item:

page-thingy-column-cell

component: oh-list-card
config:
  simpleList: false
  title: Systemtest
slots:
  default:
    - component: oh-label-item
      config:
        item: Wohnzimmer_Tests
        title: Wohnzimmer
        icon: f7:arrow_right_circle
        action: rule
        actionRule: Test_Wohnzimmer
        actionFeedback: Starte mit den Tests
        iconUseState: false

2 Likes