Hallo,
ich habe eine Frage zur Verwendung von einem Shellypro2.
Ich habe mehrere Geräte vom Typ Shelly und unter anderem 2 Shellypro2.
Zur Überwachung der Shellypro2 auf funktionalität wollte ich den readingswatcher nutzen.
Leider erhalte ich so selten readingupdates das der readingwatcher keinen Sinn macht. Auf Schaltbefehle reagiert er sofort. Aber von sichaus senden beide shelly nur sehr selten.
So ca 1x am Tag (gefühlt). Andere hingegen kommen auf einen 5 Minuten Rythmus.
Hatte schonmal jeamd so ein Problem?
Im Shelly sind alle Haken gesetzt bei Mqtt. Firmware ist die neueste.
Fehlt mir eventuell ein readinglist Eintrag?
defmod shellypro2_a0dd6c9effb0 MQTT2_DEVICE shellypro2_a0dd6c9effb0
attr shellypro2_a0dd6c9effb0 alias shellypro2-NachtabsenkungRicoEG
attr shellypro2_a0dd6c9effb0 autocreate 1
attr shellypro2_a0dd6c9effb0 comment Channel 1 for shellypro2_a0dd6c9effb0, see also shellypro2_a0dd6c9effb0_CH2
attr shellypro2_a0dd6c9effb0 devStateIcon {my $onl = ReadingsVal($name,'online','false') eq 'false'?'10px-kreis-rot': ReadingsVal($name,'new_fw','false') eq 'true' ? '10px-kreis-gelb' : '10px-kreis-gruen';; $onl = FW_makeImage($onl);; my $light = FW_makeImage(ReadingsVal($name,'state','off'));; my $temp = ReadingsVal($name,'temperature_tC','-100');; my $ip = ReadingsVal($name,'ip','none');; qq(<a href="http://$ip" target="_blank">${onl}</a><a href="/fhem?cmd.dummy=set $name toggle&XHR=1">${light}</a><div>Temp: $temp °C</div>)}
attr shellypro2_a0dd6c9effb0 devicetopic shellypro2-a0dd6c9effb0
attr shellypro2_a0dd6c9effb0 genericDeviceType switch
attr shellypro2_a0dd6c9effb0 group Relay Nachtabsenkung
attr shellypro2_a0dd6c9effb0 icon message_socket
attr shellypro2_a0dd6c9effb0 jsonMap params_switch_0_state:state temperature_tC:temperature params_switch_0_temperature_tF:0 params_wifi_sta_ip:ip
attr shellypro2_a0dd6c9effb0 model shellypro2
attr shellypro2_a0dd6c9effb0 readingList $DEVICETOPIC/online:.* online\
$DEVICETOPIC/events/rpc:.* { return if $EVENT =~ m{switch:[1-3]};; $EVENT =~ s/"output":true/"state":"on"/g;; $EVENT =~ s/"output":false/"state":"off"/g;; json2nameValue($EVENT,'',$JSONMAP) }\
$DEVICETOPIC/status/switch.0:.* { json2nameValue($EVENT, '', $JSONMAP) }\
$DEVICETOPIC/status/mqtt:.* { json2nameValue($EVENT, '', $JSONMAP) }\
fhem2shelly/rpc:.* {}\
shellypro2_a0dd6c9effb0:shellypro2-a0dd6c9effb0/status/knx:.* knx\
shellypro2_a0dd6c9effb0:shellypro2-a0dd6c9effb0/status/sys:.* { json2nameValue($EVENT) }\
shellypro2_a0dd6c9effb0:shellypro2-a0dd6c9effb0/status/cloud:.* { json2nameValue($EVENT) }\
shellypro2_a0dd6c9effb0:shellypro2-a0dd6c9effb0/status/wifi:.* { json2nameValue($EVENT) }\
shellypro2_a0dd6c9effb0:shellypro2-a0dd6c9effb0/status/ble:.* ble\
shellypro2_a0dd6c9effb0:shellypro2-a0dd6c9effb0/status/bthome:.* { json2nameValue($EVENT) }\
shellypro2_a0dd6c9effb0:shellypro2-a0dd6c9effb0/status/eth:.* { json2nameValue($EVENT) }\
shellypro2_a0dd6c9effb0:shellypro2-a0dd6c9effb0/status/input_0:.* { json2nameValue($EVENT) }\
shellypro2_a0dd6c9effb0:shellypro2-a0dd6c9effb0/status/input_1:.* { json2nameValue($EVENT) }\
shellypro2_a0dd6c9effb0:shellypro2-a0dd6c9effb0/status/ws:.* { json2nameValue($EVENT) }
attr shellypro2_a0dd6c9effb0 readingsWatcher 8000,false,online
attr shellypro2_a0dd6c9effb0 room HWRaum
attr shellypro2_a0dd6c9effb0 setList toggle:noArg $DEVICETOPIC/rpc {"id":1,"src":"fhem2shelly","method":"Switch.Toggle","params": {"id":0}}\
off:noArg $DEVICETOPIC/rpc {"id":1,"src":"fhem2shelly","method":"Switch.Set","params": {"id":0,"on":false}}\
on:noArg $DEVICETOPIC/rpc {"id":1,"src":"fhem2shelly","method":"Switch.Set","params": {"id":0,"on":true}}\
on-for-timer $DEVICETOPIC/rpc {"id":1,"src":"fhem2shelly","method":"Switch.Set","params": {"id":0,"on":true,"toggle_after":$EVTPART1}}\
off-for-timer $DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Switch.Set","params": {"id":0,"on":false,"toggle_after":$EVTPART1}}\
x_update:noArg $DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Shelly.Update","params": {"stage":"stable"}}\
x_reboot:noArg $DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Shelly.Reboot"}
Vermutlich gibt es kein regelmäßiges update da der Shelly keine PM funktion hat. Um dennoch regelmäßige updates zu erhalten habe ich ein script basteln lassen.
Danke an claude.ai ;-)
// Shelly Pro 2 Online-Status Script - Sendet alle 10 Sekunden ein Online-Signal an FHEM via MQTT
// Dieses Script verwendet die bereits vorhandene MQTT-Verbindung
let intervalId = null;
let deviceId = Shelly.getDeviceInfo().id;
// Verwende beide Topic-Formate zur Sicherheit
let onlineTopic1 = "shellypro2-" + deviceId + "/online"; // Format: shellypro2-a0dd6c9effb0/online
let onlineTopic2 = "shellies/shellypro2-" + deviceId + "/online"; // Format: shellies/shellypro2-a0dd6c9effb0/online
// Funktion zum Senden des Online-Status über MQTT
function publishOnlineStatus() {
// Sende "true" als Online-Status an beide Topics
MQTT.publish(onlineTopic1, "true", 1, true); // Mit retained-Flag
MQTT.publish(onlineTopic2, "true", 1, true); // Mit retained-Flag
console.log("Online-Status veröffentlicht unter " + onlineTopic1 + " und " + onlineTopic2);
}
// Starte den Status-Timer
function startStatusTimer() {
if (intervalId !== null) {
Timer.clear(intervalId);
}
// Status initial senden
publishOnlineStatus();
// Status alle 10 Sekunden senden (10000 ms)
intervalId = Timer.set(10000, true, publishOnlineStatus);
console.log("Online-Status-Timer gestartet - Sendet alle 10 Sekunden");
}
// Bei Script-Start
print("Starte Shelly Online-Status Script für FHEM...");
startStatusTimer();
// Event-Handler für MQTT-Verbindungsänderungen
Shelly.addStatusHandler(function(status) {
if (status.component === "mqtt") {
if (status.delta.connected === true) {
console.log("MQTT verbunden - Starte Online-Status-Timer neu");
publishOnlineStatus(); // Sofort online-Status senden
startStatusTimer();
} else if (status.delta.connected === false) {
console.log("MQTT getrennt - Timer pausiert");
if (intervalId !== null) {
Timer.clear(intervalId);
intervalId = null;
}
}
}
});
// Script wird ausgeführt, bis es manuell gestoppt wird oder der Shelly neu startet
Gruß rico