Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Asetus poissaolotunneille
- const PoissaKotoaTuuletusTunnit = [4, 10, 16, 22];
- // Skripti alkaa tästä
- let RoundRobin = 0; let SwitchStatus = false;
- Timer.set(60000, true, function () {
- if (RoundRobin === 0) { CheckSwitchStatus(); RoundRobin = 1; }
- if (RoundRobin === 1) { SetRelayStatus(); RoundRobin = 0; }
- });
- function CheckSwitchStatus() {
- // Check virtual switch status - TODO!
- Shelly.call("Input.GetStatus", "<minkä inputin tietoa haetaan, pareametri tähän>", function(res) {
- // Asetetaan muuttujaan inputin tila
- // SwitchStatus = res....
- }, null);
- }
- function SetRelayStatus() {
- // Ollaan kotona, pidetään tuuletus päällä
- if (SwitchStatus === false) { Shelly.call("Switch.Set", "{ id: 0, on:true}", null, null); return; }
- // Ollaan pois kotoa, rele päälle jos on haluttu tunti, muuten pois päältä
- let currentHour = new Date().getHours();
- if (PoissaKotoaTuuletusTunnit.indexOf(currentHour) > -1) {
- // IV päälle, koska on tuuletustunti
- Shelly.call("Switch.Set", "{ id: 0, on:true}", null, null);
- return;
- }
- else
- {
- // IV pois päältä, koska ei ole tuuletustunti
- Shelly.call("Switch.Set", "{ id: 0, on:false}", null, null);
- return;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement