Kasutaja tarvikud

Lehe tööriistad


shelly:skriptid

Erinevused

Siin näed erinevusi valitud versiooni ja hetkel kehtiva lehekülje vahel.

Lõlita võrdlemise vaatele

Next revision
Previous revision
shelly:skriptid [2025/01/23 12:06] – tekitatud sashelly:skriptid [2026/01/19 11:19] (Hetkel kehtiv) sa
Rida 1: Rida 1:
 +[[https://github.com/LeivoSepp/Smart-heating-management-with-Shelly |Nordpoolikasutav kütte script]]
 +
 +
 +[[https://www.shelly.com/blogs/scripts-library/shelly-gen2-ble-gateway-script-for-blu-button1-integration |Shelly Gen2 BLE Gateway Script for BLU Button1 Integration]]
 +
 +
 +
 [[https://haus-automatisierung.com/hardware/shelly/2023/09/02/shelly-blu-motion.html|BLU sensori script]] [[https://haus-automatisierung.com/hardware/shelly/2023/09/02/shelly-blu-motion.html|BLU sensori script]]
 +
 +Gemini tehtud script 15 lülitus
 +<code>
 +// SEADISTUSED
 +let config = {
 +  // Hind, millest ODAVAMAL juhul lülitatakse relee SISSE (senti/kWh koos KM-ga)
 +  minPrice: 5.0, 
 +
 +  // Hind, millest KALLIMAL juhul lülitatakse relee VÄLJA (senti/kWh koos KM-ga)
 +  maxPrice: 20.0, 
 +
 +  // Shelly relee number (tavaliselt 0)
 +  relayId: 0, 
 +
 +  // Käibemaks (1.22 tähendab 22%) - Elering annab hinna ilma käibemaksuta
 +  vat: 1.22,
 +  
 +  // Kui tihti kontrollida hinda (millisekundites). 15 min = 900000
 +  interval: 900000 
 +};
 +
 +// Eleringi API URL (praegune hind)
 +let url = "https://dashboard.elering.ee/api/nps/price/EE/current";
 +
 +function checkPriceAndSwitch() {
 +  Shelly.call("HTTP.GET", { url: url }, function (response, error_code, error_message) {
 +    if (error_code !== 0) {
 +      print("Viga andmete saamisel Eleringist!");
 +      return;
 +    }
 +
 +    let json = JSON.parse(response.body);
 +    
 +    if (json.success && json.data && json.data.length > 0) {
 +      // Elering annab hinna EUR/MWh, teisendame senti/kWh ja lisame käibemaksu
 +      let rawPrice = json.data[0].price; // EUR/MWh
 +      let finalPrice = (rawPrice / 10) * config.vat; // senti/kWh koos KM
 +
 +      print("Praegune börsihind: " + finalPrice.toFixed(2) + " senti/kWh");
 +
 +      // Loogika lülitamiseks
 +      if (finalPrice <= config.minPrice) {
 +        print("Hind on odav. Lülitan relee SISSE.");
 +        Shelly.call("Switch.Set", { id: config.relayId, on: true });
 +      } 
 +      else if (finalPrice >= config.maxPrice) {
 +        print("Hind on kallis. Lülitan relee VÄLJA.");
 +        Shelly.call("Switch.Set", { id: config.relayId, on: false });
 +      } 
 +      else {
 +        print("Hind on vahemikus (" + config.minPrice + " - " + config.maxPrice + "). Olekut ei muudeta.");
 +        Shelly.call("Switch.Set", { id: config.relayId, on: true });
 +      }
 +    } else {
 +      print("Viga andmete lugemisel vastusest.");
 +    }
 +  });
 +}
 +
 +// Käivita kohe skripti startimisel
 +checkPriceAndSwitch();
 +
 +// Käivita taimer iga 15 minuti järel
 +Timer.set(config.interval, true, function () {
 +  checkPriceAndSwitch();
 +});
 +
 +</code>
shelly/skriptid.1737626797.txt.gz · Viimati muutnud: persoon sa