Advertisement
ApiSpotHintaFi

Untitled

Nov 21st, 2023 (edited)
848
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 1.29 KB | Source Code | 0 0
  1. // Asetus poissaolotunneille
  2. const PoissaKotoaTuuletusTunnit = [4, 10, 16, 22];
  3.  
  4. // Skripti alkaa tästä
  5. let RoundRobin = 0; let SwitchStatus = false;
  6. Timer.set(60000, true, function () {
  7.  
  8.     if (RoundRobin === 0) { CheckSwitchStatus(); RoundRobin = 1; }
  9.     if (RoundRobin === 1) { SetRelayStatus(); RoundRobin = 0; }
  10. });
  11.  
  12. function CheckSwitchStatus() {
  13.  
  14.     // Check virtual switch status - TODO!    
  15.     Shelly.call("Input.GetStatus", "<minkä inputin tietoa haetaan, pareametri tähän>", function(res) {
  16.         // Asetetaan muuttujaan inputin tila
  17.         // SwitchStatus = res....
  18.     }, null);
  19.  
  20. }
  21.  
  22. function SetRelayStatus() {
  23.  
  24.     // Ollaan kotona, pidetään tuuletus päällä
  25.     if (SwitchStatus === false) { Shelly.call("Switch.Set", "{ id: 0, on:true}", null, null); return; }
  26.  
  27.     // Ollaan pois kotoa, rele päälle jos on haluttu tunti, muuten pois päältä
  28.     let currentHour = new Date().getHours();
  29.  
  30.     if (PoissaKotoaTuuletusTunnit.indexOf(currentHour) > -1) {
  31.         // IV päälle, koska on tuuletustunti
  32.         Shelly.call("Switch.Set", "{ id: 0, on:true}", null, null);
  33.         return;
  34.     }
  35.     else
  36.     {
  37.         // IV pois päältä, koska ei ole tuuletustunti
  38.         Shelly.call("Switch.Set", "{ id: 0, on:false}", null, null);
  39.         return;
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement