-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
For testing updates to "Vesivaraaja" scripts. Both scripts were missi…
…ng the feature to not touch the relay if status is not changing frrom the previous hours. This allows user to manually change the relay status and script does not change the status in the start of next hour, if status according to script should not be changed.
- Loading branch information
Showing
7 changed files
with
30 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,37 @@ | ||
// Kiitos tuestasi: https://www.buymeacoffee.com/spothintafi | ||
// Tuetut Shelly ohjelmistot: 1.0.3 - 1.4.2. Skriptin versio: 2024-09-09 | ||
// Tuetut Shelly ohjelmistot: 1.0.3 - 1.4.2. Skriptin versio: 2024-10-09 | ||
|
||
// ASETUKSET | ||
let Rankit = [1, 2, 3]; // Listaa 'rankit' (eli tunnin järjestysnumero hinnan mukaan), jolloin rele kytketään | ||
let Rele = 0; // Ohjattavan releen numero | ||
let Rankit = [1, 2, 3]; // Listaa 'rankit' (eli tunnin järjestysnumero hinnan mukaan), jolloin rele kytketään | ||
let Rele = 0; // Ohjattavan releen numero | ||
let Yotunnit = [22, 23, 0, 1, 2, 3, 4, 5, 6]; // Yösiirron tunnit. Näihin ei tarvitse normaalisti koskea (edes kellonsiirron aikaan). | ||
let Hintaero = -1.43; // Paljonko sähkön siirtohinta on halvempi yösiirron aikaan? | ||
let Hintaero = -1.43; // Paljonko sähkön siirtohinta on halvempi yösiirron aikaan? | ||
let Varatunnit = [3, 4, 5]; // Tunnit jolloin rele kytketään, mikäli Internet yhteys ei toimi tai palvelu on alhaalla | ||
|
||
// KOODI | ||
let url = "https://api.spot-hinta.fi/JustNowRanksAndPrice?priorityHours=" + Yotunnit.join() + "&priceModifier=" + Hintaero + "&ranksAllowed=" + Rankit.join(); | ||
let hour = -1; print("WaterBoiler: Ohjaus käynnistyy 30 sekunnissa."); | ||
let hour = -1; let previousAction = ""; print("WaterBoiler: Ohjaus käynnistyy 30 sekunnissa."); | ||
Timer.set(30000, true, function () { | ||
if (hour == new Date().getHours()) { print("WaterBoiler: Odotetaan tunnin vaihtumista."); return; } | ||
Shelly.call("HTTP.GET", { url: url, timeout: 15, ssl_ca: "*" }, function (res, err) { | ||
hour = (err != 0 || res == null || (res.code !== 200 && res.code !== 400)) ? -1 : new Date().getHours(); | ||
let on = false; | ||
if (hour === -1) { | ||
previousAction = ""; | ||
if (Varatunnit.indexOf(new Date().getHours()) > -1) { | ||
on = true; hour = new Date().getHours(); | ||
print("WaterBoiler: Virhetilanne. Kuluva tunti on varatunti: rele kytketään päälle tämän tunnin ajaksi."); | ||
} else { | ||
print("WaterBoiler: Virhetilanne. Kuluva tunti ei ole varatunti: relettä ei kytketä. Yhteyttä yritetään uudestaan."); | ||
} | ||
} else { if (res.code === 200) { on = true; } } | ||
Shelly.call("Switch.Set", "{ id:" + Rele + ", on:" + on + "}", null, null); | ||
print("WaterBoiler: Kytketty " + (on ? "päälle" : "pois päältä")); | ||
|
||
if (previousAction !== on) { | ||
Shelly.call("Switch.Set", "{ id:" + Rele + ", on:" + on + "}", null, null); | ||
print("WaterBoiler: Kytketty " + (on ? "päälle" : "pois päältä")); | ||
previousAction = on; | ||
} else { | ||
print("WaterBoiler: Releen tilaa ei muutettu, koska se olisi sama kuin edellisellä tunnilla."); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters