Beiträge von Gspjb

    Small report:

    1. The Shelly firmware developers fixed the missing shelly/online true problem. Most probably in version in 1.4.0 with the changelog entry: MQTT Allow more than one outstanding publish request (avoid MQTT queue overflows)
    2. My scripts on the Shelly work without any issues since spring. Every part of the system like hardware, wifi, mqtt, scripting works reliable since then.

    Ich empfehle die Berechnung des Energie in der Puffer in kWh. Ich mache das in Home Assistant für Heizungs Puffer und auch für Warmwasser und anzeige in kWh und % auch. Und kann mann mit mehrere sensoren die Volumen des Puffers verteilen in Formel so:

    kWh = ((LiternUnten * 4190 * (CelsiusUnten - MinimalCelsius) / 3600000) + (LiternOben * 4190 * (CelsiusOben - MinimalCelsius) / 3600000))

    Home Assistant template für 400L Warmwasser Tank mit 2 sensoren und 11 Celsius Leitungswasser temperatur:

           {% if states('sensor.oben') != 'unavailable' and states('sensor.oben') != 'unknown' and states('sensor.unten') != 'unavailable' and states('sensor.unten') != 'unknown' -%}
           {{ ((200*4190*(states('sensor.unten')|float - 11) / 3600000) + (200*4190*(states('sensor.oben')|float - 11) / 3600000)) | round(1) }}
           {%- else -%}
           {{ 0 }}
           {%- endif %}

    Und prozent kalkulieren kann mann einfach mit kalkulieren für maximale Temperatur und einfach dividieren die aktuelle damit.

    Hier ein online calculator: https://www.omnicalculator.com/physics/water-heating

    (Entschuldigung, mein Deutsch ist nicht besonders gut.)

    Zitat

    I don't know if it's professional to call an LWT retained, but that makes it understandable.

    I think in almost all the cases it's better to send online/offline and LWT retained. If sent as not retained the clients connecting after the online/offline/lwt message won't know the status of the other client until it sends its status again which happens at connection/disconnection to the broker. And this can be a lot of time, even years. But if the message was sent via retain flag, the newly connected client gets the retained messages from the broker, so it will know the status of the other client immediately.

    Yes, it's without "status", I just misstyped here. It looks like a bug in firmware. The problem is, that it does not send "shelly/online true" when it connects to the broker. Even with good signal if I reboot the shelly sometimes it doesn't send "shelly/online true" at boot, sometimes it sends. I wrote my findings to the support ticket, we will see.

    I think MQTT.setConnectHandler won't work. That callback will be called when the MQTT connection is ready, but setting the LWT has to be done at connection time and I have never seen a way to change it after the client is connected.

    With the LWT you instruct the broker to publish that message when your client disappears from the broker.

    I fixed it by sending every minute the shelly/online true :) Maybe they will resolve this bug, but if not, I will look into the connection handler way and I will add the isConnected() too into the script to not fill up the queue of the Shelly when disconnected. Thanks again.

    Good to know, that it works without problems for you. Thanks for the info.

    Today I had the first problem: the Shelly is far from the Wifi antennas so the RSSI fluctuates around -78 dBm. It disconnected from the wifi network and when reconnected didn't updated it's /status/online topic on mqtt to true, so the LWT remained forever (/status/online false). The script worked, so that's cool, but I had to manually change the online status on mqtt to true to let Home Assistant process the data coming from the Shelly (if /status/online is false, it appears as unavailable device). Even a reboot didn't helped. I opened a ticket on this at the Shelly Support page. We will see, what that was. I think it's a bug in the firmware.

    I went with the logic on the Shelly approach. The main reason was to mitigate WIFI related problems, so the Shelly is able to control the hot water production even if it has no connection to the MQTT server (i.e. Home Assistant).

    To make things reliable I made the following so far:

    1. I have two scripts running on the Shelly.

    2. The first one is the main controller script.

    3. The second is a watchdog script.

    4. In the controller script in case of a logic error (for example can not read one of the sensors or temperature is outside of normal range) I switch of the pump's relay and do nothing until everything is okay in the next try (the logic is timer based, so it runs periodically every 60s).

    5. The watchdog script handles the script status change events. If the main script stops, the watchdog switches of the pump's relay.

    6. The watchdog periodically publishes the status of the main script on MQTT. (The status update over MQTT is enabled in the Shelly settings, but in case of Home Assistant restart without this I won't get the status of the running script as it is published only on change.)

    7. Home assistant alerts me if the control script's status changes from running to stopped.

    8. Home assistant alerts me if there is not enough hot water.

    Any tips on this?

    Until now it works fine. I like this scripting possibility on the Shelly, I even didn't know that this is available on the Shellys when I bought the Plus 2PM. I have to polish the scripts further and I will extend it with control of the 2nd relay in the Shelly, which will switch the electric heater in the tank based on water usage and weather forecast published on MQTT by Home Assistant. (The electric heater will be switched by a high power contactor not the small relay in the Shelly, and I have RC snubbers certified for mains use on both loads).

    Hello,

    My old solar water heater controller died and I'm on the way replacing it with a Shelly 2PM + Add-on. Basically the Shelly will read 1 thermistor (residing in the collector on the roof) and 5 DS18B20s, and switch on/off the pump circulating the collector water.

    I'm new to Shelly but a veteran in Home Assistant and have some electronic background and I am a software engineer by trade. I need your experience on the following questions. Anything is really appreciated, from "I have one shelly controlling XY for a year without any problem" to more technical answers.

    1. Is Shelly 2PM + Add-on reliable enough for this type off control? Reliability in general and for example voltage spikes caused by storms, may that alter/clear the config/script, does it have some kind of preventive solution to this (like checksuming the firmware and scripts and doing something when the check fails).

    2. Is Shelly scripting reliable enough to control this? Reading 6 temp sensors, math calculation based on the data and switching the pump on/off + MQTT reporting.

    3. Do you know some links to blogs or docs about reliable scripting on a Shelly? For example something about internal or external watchdogs, device monitoring (CPU, RAM, internal temperature etc), script monitoring.

    4. What would you do with reliability in mind: a) use the Shelly just as an input/output device and put the logic into Home Assistant or b) let the Shelly do the control via scripting and Home Assistant only for displaying the data? Both have advantages in reliability perspective, and I don't know which way would be better.

    Thanks in advance.

    Regards