# \[Resolved\] Gladys Plus slowdowns in Canada

**URL:** <https://community.gladysassistant.com/t/resolu-lenteurs-gladys-plus-au-canada/9270>\
**Category:** Gladys Plus\
**Created:** [December 26, 2024, 8:01pm UTC](https://community.gladysassistant.com/t/resolu-lenteurs-gladys-plus-au-canada/9270 "2024-12-26T20:01:23Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lmilcent](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/lmilcent/32/7023_2.png) [@lmilcent](https://community.gladysassistant.com/u/lmilcent)\
**Post date:** [December 26, 2024, 8:01pm UTC](https://community.gladysassistant.com/t/resolu-lenteurs-gladys-plus-au-canada/9270/1 "2024-12-26T20:01:23Z")

</div>

Hi @pierre-gilles,

I don’t know if it’s due to my location (Canada), but I’m noticing significant slowdowns when I control my devices via Gladys Plus.

More context:

- Loading the Gladys Plus page: fast (about 2 sec, vs 1.3 sec locally)
- Controlling a plug (On/Off): slow (up to 30 seconds) vs less than 2 sec at worst locally
- Controlling a thermostat (setpoint): regularly fails vs less than 2 sec locally

I thought it might be an issue on my end, but I have a symmetric 3Gbps fiber connection and everything works fine locally.

---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [January 2, 2025, 9:37am UTC](https://community.gladysassistant.com/t/resolu-lenteurs-gladys-plus-au-canada/9270/2 "2025-01-02T09:37:27Z")

</div>

Hi @lmilcent 🙂 You are the first Canadian user (woohoo!), so there may be a bit of fine-tuning to do aha

I’d really like to be more active in North America so it’s the perfect opportunity for me to test my offering over there 😃

I’ll send you information in private so you can run some tests

---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [January 2, 2025, 3:06pm UTC](https://community.gladysassistant.com/t/resolu-lenteurs-gladys-plus-au-canada/9270/3 "2025-01-02T15:06:35Z")

</div>

I’m posting the final message here: it wasn’t related to Gladys Plus or to Canada (125 ms response time tested by @lmilcent from Canada), but to scenes that were too aggressive every 5 seconds, which were saturating the Gladys event queue 🙂

---

<div class="post-metadata">

**Author:** ![lmilcent](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/lmilcent/32/7023_2.png) [@lmilcent](https://community.gladysassistant.com/u/lmilcent)\
**Post date:** [January 2, 2025, 7:03pm UTC](https://community.gladysassistant.com/t/resolu-lenteurs-gladys-plus-au-canada/9270/4 "2025-01-02T19:03:08Z")

</div>

Thanks @pierre-gilles for the support and for understanding what could make Gladys Plus unstable.

# Origin of the problem

To explain to everyone in detail, I have a Sinopé connected thermostat ([Sinopé TH1123ZB control via MQTT | Zigbee2MQTT](https://www.zigbee2mqtt.io/devices/TH1123ZB.html#sinop%25C3%25A9-th1123zb)), which seems to have a bug preventing it from sending me consumption values. So when the heating turns on, it always shows «&nbsp;0 W&nbsp;» consumed instantaneously.  
Since the heating period runs in 15-second intervals, I had to retrieve this value very frequently to avoid missing a cycle.

# Workaround with a scene (cause of the problem with Gladys Plus)

I had created a scene like the following image, but applied to 3 thermostats (only one is shown there). This scene ran **every 5 seconds**.  
Gladys running locally didn’t complain, it ran fine without instability and without using too much CPU. But when I used Gladys Plus, it was another story — I sometimes experienced delays of up to 30 seconds to command a plug!!

 ![image](https://gladys-assistant-community.b-cdn.net/uploads/default/original/3X/9/4/94e661512aa3acbb8972c4b9410e221f363d64c8.png)

# Final solution

To force my thermostats to resend their up-to-date data regularly, without asking Gladys to do the work (since it causes side effects), I did the same thing but directly with Zigbee2MQTT.

## Extensions

Zigbee2MQTT offers an extensions system, allowing you to add features. You need to write JavaScript code that will be executed on different events.

In my case, I made it so that every 5 seconds, my three thermostats are forced to be updated for their power consumption values.  
Result: no more slowdowns on Gladys and I now get my data regularly.

 ![image](https://gladys-assistant-community.b-cdn.net/uploads/default/original/3X/4/0/40c75f9b6af7d248a2e350ccc6ca9180cbd2df14.png)

Here is the code as text:

```auto
class ForceUpdateSinopeExtension{
    constructor(zigbee, mqtt, state, publishEntityState, eventBus, settings, logger) {
        logger.info('Loaded ForceUpdateSinopeExtension');
        this.mqttBaseTopic = settings.get().mqtt.base_topic;
        this.eventBus = eventBus;
        this.mqtt = mqtt;
        this.eventBus.on('stateChange', this.onStateChange.bind(this), this.constructor.name);

        // List of devices to update
        this.devices = [
          'bureau-thermostat-sinope',
          'piecedevie-thermostat-sinope',
          'chambreenfant-thermostat-sinope'
        ];
        this.lastMessageTime = Date.now() / 1000;
    }

    
    async onStateChange() {
        const now = Date.now() / 1000; // get current time in seconds
        if (now - this.lastMessageTime >= 5) { // check if 5 seconds have passed since last message
            this.lastMessageTime = now;
            console.log('----> Forcing updates of sinope devices (every 5 sec).');
            // update all values from a list
            for (const device of this.devices) {
                const topic = `${this.mqttBaseTopic}/${device}/get`;
                const data = {
                  'power': true,
                  'voltage': true,
                  'current': true,
                  'energy': true
                }
                this.mqtt.onMessage(topic, JSON.stringify(data));
            }
        }
    }

    async onMQTTMessage(topic, message) {
        // console.log({topic, message});
    }

    async stop() {
        this.eventBus.removeListeners(this.constructor.name);
    }
}

module.exports = ForceUpdateSinopeExtension;

```

---

<div class="post-metadata">

**Author:** ![lmilcent](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/lmilcent/32/7023_2.png) [@lmilcent](https://community.gladysassistant.com/u/lmilcent)\
**Post date:** [January 5, 2025, 1:00pm UTC](https://community.gladysassistant.com/t/resolu-lenteurs-gladys-plus-au-canada/9270/5 "2025-01-05T13:00:07Z")

</div>

FYI, extensions do not appear to be backed up by Gladys Plus. You should therefore keep a copy of the code locally so you can restore it if needed.
