Script for heating

Hey folks. Winter is coming (well, at least around here on the upper half of this globe). With energy prices going through the roof I thought it’d be a good time to share my script with you folks and see what other ideas you come up with to have a nice and cozy home while still saving some energy with heating.

The situation here at my place is that I have old school radiators, heating with warm water and I’ve put ZigBee radiator thermostat valves on them so I can control them with nymea. Along with that, I’ve mounted door/window sensors to the windows we use normally for ventilation of the place.

So, here’s my current script:

import QtQuick 2.0
import nymea 1.0

Item {
    id: root
    
    property double comfortTemp: 20.5
    property double bedroomComfortTemp: 19
    property double offTemp: 5
    
    property bool someoneAtHome: p_micha.value === true || p_domi.value === true

    ThingState {
        id: t_bedroom
        thingId: "{5a890881-1953-49dc-ae27-2cb1f947aad7}" // Schlafzimmer
        stateName: "targetTemperature"
        value: root.someoneAtHome && s_bedroom.isClosed ? root.bedroomComfortTemp : root.offTemp
    }
    ThingState {
        id: t_livingroom
        thingId: "{1367a531-e931-4b1b-b4cf-bf51d955c6b1}" // Wohnzimmer
        stateName: "targetTemperature"
        value: root.someoneAtHome && s_livingroom.isClosed ? root.comfortTemp : root.offTemp
    }
    ThingState {
        id: t_kitchen
        thingId: "{a75d66f2-89e9-4a98-9172-9d00a31bd583}" // Küche
        stateName: "targetTemperature"
        value: root.someoneAtHome && s_balconydoor.isClosed ? root.comfortTemp : root.offTemp 
    }
    ThingState {
        id: t_diningroom
        thingId: "{b7523864-30ae-4544-8024-14b54e8edd57}" // Essbereich
        stateName: "targetTemperature"
        value: root.someoneAtHome && s_balconydoor.isClosed ? root.comfortTemp : root.offTemp
    }
    ThingState {
        id: t_bathroom
        thingId: "{79d6e31a-186b-4cab-bb87-9ae161918896}" // Badezimmer
        stateName: "targetTemperature"
        value: root.someoneAtHome && (a_bathroomMorning.active || a_bathroomEvening.active) ? root.comfortTemp : root.offTemp
    }
    ThingState {
        id: t_childrensroom
        thingId: "{ee342492-99ec-40cc-bef1-bd4b00f136ad}" // Kinderzimmer
        stateName: "targetTemperature"
        value: root.someoneAtHome && s_childrensroom.isClosed ? root.comfortTemp : root.offTemp
    }


    ThingState {
        id: s_bedroom
        thingId: "{7c38f531-1fea-4f4e-8aa7-46928da5744f}" // Schlafzimmer
        stateName: "closed"
        readonly property bool isClosed: value === true
    }
    ThingState {
        id: s_balconydoor
        thingId: "{525b50e4-c97c-4f04-8573-dc934787ed76}" // Balkontür
        stateName: "closed"
        readonly property bool isClosed: value === true        
    }
    ThingState {
        id: s_livingroom
        thingId: "{996089ec-fc31-4f6b-b291-8acb8f9958b3}" // Wohnzimmer
        stateName: "closed"
        readonly property bool isClosed: value === true
    }
    ThingState {
        id: s_childrensroom
        thingId: "{c9d7ab00-5c9d-4c93-96bf-a6b0bccab016}" // Kinderzimmer
        stateName: "closed"
        readonly property bool isClosed: value === true
    }

    ThingState {
        id: p_micha
        thingId: "{c15019e3-5813-49bc-ab00-22438c51988f}" // Pixel 5
        stateName: "isPresent"
    }
    ThingState {
        id: p_domi
        thingId: "{343f1d89-0c08-48a4-9294-e7799d5f615f}" // Pixel 3a
        stateName: "isPresent"
    }
    
    Alarm {
        id: a_bathroomMorning
        weekDays: Alarm.AllDays
        time: "07:00"
        endTime: "09:00"
    }
    Alarm {
        id: a_bathroomEvening
        weekDays: Alarm.AllDays
        time: "18:00"
        endTime: "19:00"
    }
}

It will now keep a steady 20.5°C when someone of us is at home. This is detected by using the networkdetector plugin and monitor our smartphones. If at least one of phones are connected to the WiFi, we’ll be considered at home.

The bedroom is special handled, given we don’t need a 20.5°C in there but prefer a bit lower temp there, just personal preference.

If a window (or the balcony door) is being opened for getting some fresh air in, the respective radiators are shut off and turned back on when the window/door is closed again.

Also the Bathroom is special. For one, we don’t have a window there (kinda sucks, but oh well, can’t script a window in there) and we also don’t need that room being heated all the time, given a steady temperature is maintained by the rooms around it anyways. We just give it a quick bump in the morning when we normally take a shower, and in the evening when we’re washing the baby.

I’ve set the “offTemp” to 5°C. That’s ok here, given we live in a flat of a larger house, it’s never going to actually get that cold anyways, given the neighbors are heating their places too. In a standalone house that might not be so good as cooling everything down to 5° and heating it back up to 21° is probably not a good idea when it comes to saving energy. AFAICT, ideally one would maintain a relatively constant temperature, while still having radiators as low as possible most of the time.

What do you guys think?

Oh, btw, if scripting is not your thing, all of this can be done with rules too!