This Shelly script is designed to retrieve energy market prices from Elering and activate heating during the most cost-effective hours each day, employing various algorithms.
This Shelly script is designed to retrieve energy market prices from Elering and activate heating during the most cost-effective hours each day, employing various algorithms.
The script runs daily after 23:00 or as necessary during the day to set up heating time slots for the upcoming period.
heatingMode: HEAT24H_FCST
- Heating mode, options are described in the following table.You can customize or change the heating modes to better suit your personal preferences and specific situations. This flexibility allows you to adjust the system based on your needs, energy considerations, and comfort requirements.
Heating mode | Description | Best usage |
---|---|---|
HEAT24H_FCST |
The heating time for 24-hour period depends on the outside temperature. | Concrete floor heating system or big water tank capable of retaining thermal energy for a duration of at least 10 to 15 hours. |
HEAT12H_FCST |
The heating time for each 12-hour period depends on the outside temperature. | Gypsum (kipsivalu) floor heating system or water tank capable of retaining thermal energy for a duration of 5 to 10 hours. |
HEAT6H_FCST |
The heating time for each 6-hour period depends on the outside temperature. | Air source heat pumps, radiators or underfloor heating panels with small water tank capable of retaining energy for a duration of 3 to 6 hours. |
HEAT24H_20H |
Heating is activated during the 20 most cost-effective hours in a day. | Ventilation system. |
HEAT24H_12H |
Heating is activated during the 12 most cost-effective hours in a day. | Big water tank 1000L or more. |
HEAT24H_8H |
Heating is activated during the 8 most cost-effective hours in a day. | Big water tank 1000L or more. |
HEAT12H_6H |
Heating is activated during the six most cost-effective hours within every 12-hour period. | Big water tank 1000L or more with heavy usage. |
HEAT12H_2H |
Heating is activated during the two most cost-effective hours within every 12-hour period. | A 150L hot water boiler for a little household. |
HEAT12H_1H |
Heating is activated during the single most cost-effective hours within every 12-hour period. | A 100L hot water boiler for a single person. |
HEAT6H_2H |
Heating is activated during the two most cost-effective hours within every 6-hour period. | A 200L hot water boiler for a household with four or more people. |
HEAT6H_1H |
Heating is activated during the single most cost-effective hours within every 6-hour period. | A 100L hot water boiler for a small household with two people. |
HEAT4H_2H |
Heating is activated during the two most cost-effective hours within every 4-hour period. | A 200L hot water boiler for a household with six or more people with heavy usage. |
HEAT4H_1H |
Heating is activated during the single most cost-effective hours within every 4-hour period. | A 100L hot water boiler for a household with four or more people. |
HEAT_LOWPRICE |
Heating is only activated during hours when the price is lower than the specified alwaysOnLowPrice . |
elektrilevi: VORK2KUU
- Elektrilevi transmission fee, options are the following.Heating mode | Description |
---|---|
VORK1 |
Elektrilevi Võrk1. Day and night rate is 72 EUR/MWh |
VORK2 |
Elektrilevi Võrk2. Day 87 and night 50 EUR/MWh |
VORK2KUU |
Elektrilevi Võrk2 with monthly fee. Day 56 and night 33 EUR/MWh |
VORK4 |
Elektrilevi Võrk4. Day 37 and night 21 EUR/MWh |
NONE |
Transmission fee is set to 0. |
alwaysOnLowPrice: 10
- Keep heating always ON if energy price lower than this value (EUR/MWh).
alwaysOffHighPrice: 300
- Keep heating always OFF if energy price higher than this value (EUR/MWh).
isOutputInverted: false
- Configures the relay state to either normal or inverted.
true
- Inverted relay state. This is required by many heating systems like Nibe or Thermia.false
- Normal relay state.relayID: 0
- Configures the Shelly relay ID when employing a Shelly device with multiple relays. Default 0
.
defaultTimer: 60
- Configures the default timer duration, in minutes, for toggling the Shelly state. The default value is set to 60
to align with hourly changes in energy prices.
country: "ee"
- Specifies the country for energy prices:
ee
- Estoniafi
- Finlandlt
- Lithuanialv
- LatviaheatingCurve: 0
- Adjusts the heating curve by shifting it to the left or right. Default 0
, shifting by 1 equals 1h. This setting is applicable only if weather forecast used.
-10
- less heating10
- more heatingpowerFactor: 0.5
- Adjusts the heating curve to be either more gradual (flat) or more aggressive (steep). Default 0.5
. This setting is applicable only if weather forecast used.
0
- flat1
- steepWhen the script is stopped, all schedules are deleted. Shelly only follows the heating algorithm when the script is running.
Up to two instances of this script can run concurrently, both employing different algorithm. These instances can either operate with the same switch output using Shelly Plus 1 or use different switch outputs, as supported by devices like Shelly PRO 4PM.
Shelly allows three scripts to run simultaneously. In practice, only two heating scripts can run concurrently because the third script is reserved for the essential "watchdog" script. This "watchdog" script ensures proper cleanup when the heating script is stopped or deleted.
To mitigate the impact of power or internet outages, this script operates continuously. It checks every minute to confirm whether updates are needed for energy market prices or the current weather forecast.
The "enable" button for this script must be activated. This setting ensures that the script starts after a power outage, restart, or firmware update.
This script exclusively handles schedulers generated by its own processes. In contrast to the previous version, which featured a "delete all schedulers" command, this script is designed to delete only those schedulers that it has created.
When saving the script, avoid immediately clicking "Start" to prevent potential issues with Shelly that may occur if you initiate the start process too quickly. Initiate Start once the saving process, which may take 3-6 seconds, is complete.
This solution will only yield benefits if you have an hourly priced energy contract. If your energy contract features a flat rate, this solution will not contribute to reducing your energy bill.
This algorithm calculates the heating time for the next day based on weather forecasts. It is particularly effective for various home heating systems, including those with substantial water tanks capable of retaining thermal energy. This approach optimizes energy usage by aligning heating needs with anticipated weather conditions.
When the outside temperature is a mild +17 degrees Celsius, no heating is necessary. Conversely, as the temperature drops to -5 degrees Celsius, there is a need for some heating, and for extremely cold conditions like -20 degrees Celsius, significant amount of heating is required.
Utilizing weather forecasts allows for smart and adaptive heating management. The system will proactively adjust heating times based on the outside temperature, creating a responsive and dynamic heating schedule.
To provide accurate weather forecasts, location data is necessary. This enables the system to deliver precise predictions for your home's climate, allowing for a customized and effective heating strategy.
Ensure that your Shelly device has the correct location information by checking Shelly → Settings → Geolocation → Latitude/Longitude.
Note: Shelly's location is determined based on your internet provider's IP address, which may or may not accurately reflect your home location. Verify and update the latitude and longitude settings as needed.
The relationship between temperature and heating time is known as the heating curve.
Heating time is influenced by the insulation of your household. For instance, an old and uninsulated house may require 10 hours of heating at -5 degrees, whereas a new A-class house might only need 6 hours.
To account for these differences, the script includes the parameter heatingCurve
, allowing users to customize the heating curve based on their specific household characteristics.
heatingCurve
parameter which shifts the heating curve to the left or right, whereas shifting 1 equals 1h. The Shelly device has a maximum limit of 20 schedulers, representing the maximum heating hours the script can manage within a 24-hour period. If more heating hours are needed, the script employs a 12-hour algorithm.heatingCurve
parameter.For those interested in the mathematical aspect, the linear equation used to calculate heating time is: (Temperature Forecast) * PowerFactor + (Temperature Forecast + heatingCurve)
.
This algorithm divides heating into distinct time periods, activating heating during the most cost-effective hours within each period. It is well-suited for use cases such as hot water boilers, where usage is contingent on the household size rather than external temperature. This method optimizes energy efficiency by aligning heating with periods of lower energy costs.
In short: yes.
Here's a more detailed explanation. While your overall daily electric consumption remains the same, this script optimizes the activation of your heating devices for the most economical hours. Consequently, even with the same energy consumption, your electricity bill is reduced.
Appliances like water heaters, water tanks, ground-source or air-source heat pumps, electric radiators, underfloor electric heaters, and air conditioning are examples of energy-intensive devices that benefit from being activated during the most cost-effective times of the day.
Electricity prices can fluctuate significantly, sometimes varying up to 100 times during a day. Check electricity market prices for more information. https://dashboard.elering.ee/et/nps/price
https://raw.githubusercontent.com/LeivoSepp/Smart-heating-management-with-Shelly/master/manifest.json
flowchart TD
0[Start loop] --> A
A[Get Shelly time and location] --> K{Is weather forecast used?}
K -- Yes --> B{Get weather forecast <br> from Open-Meteo.com API}
B -- Succeeded </br>Calculate heating time --> D{Get electricity market price <br> from Elering API}
K -- No --> D
B -- Failed</br>Check again in 1 minute --> B
D -- Succeeded</br>Calculate heating schedules --> L{Check, if market price and </br> forecast data is accurate}
D -- Failed</br>Check again in 1 minute --> D
L -- Yes</br>Check again in 1 minute --> L
L -- No</br>Start the script --> 0
flowchart TD
0[Start heating script] --> A
A[Create 'watchdog' script </br>with an event handler] --> K{Is heating script </br>stopped or deleted?}
K -- Yes --> B[Find all this script schedules</br>and delete them]
Currently, in Shelly device web page, all schedules are labeled with the message "This schedule contains an invalid call method or params," and attempting to click on any schedule fails to open them.
This as a Shelly bug. It's important to note two key points regarding this issue:
The attempt to add a scheduler has failed due to the Shelly-imposed limit of 20 schedulers. This limit is applicable to the entire device, irrespective of the Shelly model, including multichannel devices such as the Pro4PM.
To address this limitation, we recommend utilizing the heating mode HEAT12H_FCST. This mode calculates schedules every twelve hours, enabling you to create up to 12 schedules within each twelve-hour cycle. This alternative mode ensures flexibility in scheduling while adhering to the device's limitations.
There is an issue within the Shelly system that may affect your experience when attempting to open scripts through the Shelly cloud or mobile app. The encountered error, "Couldn't get script," is a known bug preventing the opening of scripts larger than 15kB via these platforms.
To navigate around this inconvenience, we suggest the following workarounds:
Open the Script Through Device Web Page: Access the device web page to successfully open any script. This method provides a direct and reliable solution to view and manage your scripts seamlessly.
Alternative Solution Through Shelly Cloud: If accessing the device web page is not feasible, follow these steps on the Shelly cloud:
If any issues arise during this process, you can repeat the workaround by starting from the script deletion step.
The script saves data in Shelly KVS (Key-Value-Storage) to preserve it in case of power outages or restarts.
To access the stored data on the Shelly device web page, navigate to Advanced → KVS.
Key: schedulerIDs1
Value: [12,13,14,15,16,17,18,19,23,24]
The numeric values represent schedule ID numbers created by the script. This information is crucial for each script to identify and manage schedules associated with it. It aids in the proper deletion of outdated schedules when creating new ones is necessary.
Key: timestamp1
Value: Wed Jan 3 2024 21:13:24 GMT+0200
This timestamp indicates the time when the script successfully retrieved market prices from Elering and created schedules. While this information is primarily for your reference, it offers insights into the timeline of script activities.