-
Autor
Hallo fhem-Interessierte Shelly-Besitzer,
da aus meinen anfänglichen Spielereien mit ein paar Shellies allmählich ein produktiver Einsatz werden soll, habe ich hier bereits einige Fragen gestellt und Antworten erhalten. Dafür allen Beteiligten nochmals, vielen Dank.
Mittlerweile habe meine ersten „Gehversuche“ zurShelly Verwaltung in fhem begonnen:
Hat einer hier Interesse mitzumachen?
Code
defmod shellyFW dummy
attr shellyFW userattr fw_URL fw_TargetDir fw_otaURL
attr shellyFW fw_TargetDir /opt/fhem/www/shelly
attr shellyFW fw_URL https://api.shelly.cloud/files/firmware
attr shellyFW fw_otaURL /fhem/shelly
attr shellyFW group ShellyFW
attr shellyFW oldreadings .*_version
attr shellyFW room temp
defmod shellyFW_announce MQTT2_DEVICE
attr shellyFW_announce IODev MQTT2
attr shellyFW_announce group ShellyFW
attr shellyFW_announce readingList shellies/announce:.* {$EVENT =~ m,..id...(.*)...mac.*, ? json2nameValue($EVENT,"${1}_") : undef }
attr shellyFW_announce room temp
attr shellyFW_announce setList getType { shellyFW_GetType($NAME,$EVTPART1)}
attr shellyFW_announce stateFormat shellyCount Shellies gefunden!
attr shellyFW_announce userReadings shellyCount\
{\
shellyFW_cli_count($NAME);;\
}
defmod shellyFW_download notify shellyFW:download {shellyFW_download($NAME)}
attr shellyFW_download group ShellyFW
attr shellyFW_download room temp
defmod shellyFW_json expandJSON shellyFW:firmware:.\{.*}
attr shellyFW_json addStateEvent 1
attr shellyFW_json group ShellyFW
attr shellyFW_json room temp
defmod shellyFW_update notify shellyFW:update {shellyFW_getUpdate($NAME)}
attr shellyFW_update group ShellyFW
attr shellyFW_update room temp
defmod shellyFW_updateCeck at *05:00:00 {fhem("set shellyFW update;;;;set shellyFW download;;;;");;}
attr shellyFW_updateCeck group ShellyFW
attr shellyFW_updateCeck room temp
Muster fhem MQTT2_DEVICE:
defmod 03_Abzugshaube MQTT2_DEVICE shellyplug_s_B86F0C
attr 03_Abzugshaube IODev MQTT2
attr 03_Abzugshaube alias Abzugshaube
attr 03_Abzugshaube cmdIcon on:general_an@OrangeRed off:general_aus settings:rc_INFO@Darkblue reboot:control_standby@OrangeRed
attr 03_Abzugshaube devStateIcon {\
my $onl = ReadingsVal($name,"online","false") eq "false" ? "rot" : ReadingsVal($name,"new_fw","false") eq "true" ? "gelb" : "gruen";;\
my $light = ReadingsVal($name,"state","off");; \
my $show = "";;\
$show .= '<a href="';;\
$show .= $onl eq "gelb" ? "/fhem?cmd.dummy=set $name x_update&XHR=1\">" : "http://".ReadingsVal($name,"ip","none").' "target="_blank">';;\
$show .= FW_makeImage("10px-kreis-".$onl)."</a>";;\
\
return "<div><a href=\"/fhem?cmd.dummy=set $name toggle&XHR=1\">".FW_makeImage($light)."</a>".$show." </div>" \
\
}
attr 03_Abzugshaube devStateStyle style="text-align:right;;"
attr 03_Abzugshaube getList status:noArg status:noArg { X_PerformShellyHttpRequest($NAME,ReadingsVal($NAME,"ip","").",".$EVENT.",".ReadPassword($defs{$NAME})) }
attr 03_Abzugshaube group 9_System
attr 03_Abzugshaube icon vent_exhaust_air
attr 03_Abzugshaube model shellyplug
attr 03_Abzugshaube readingList shellies/03_Abzugshaube/relay/0:.* state\
shellies/03_Abzugshaube/relay/0:.* relay0\
shellies/03_Abzugshaube/input/0:.* input0\
shellies/03_Abzugshaube/online:.* online\
shellies/03_Abzugshaube/announce:.* { json2nameValue($EVENT) }\
shellies/announce:.* { $EVENT =~ m,..id...03_Abzugshaube...mac.*, ? json2nameValue($EVENT) : undef }\
shellyplug_s_B86F0C:shellies/03_Abzugshaube/relay/0/power:.* relay_0_power\
shellyplug_s_B86F0C:shellies/03_Abzugshaube/temperature:.* temperature\
shellyplug_s_B86F0C:shellies/03_Abzugshaube/temperature_f:.* temperature_f\
shellyplug_s_B86F0C:shellies/03_Abzugshaube/overtemperature:.* overtemperature\
shellyplug_s_B86F0C:shellies/03_Abzugshaube/relay/0/energy:.* relay_0_energy
attr 03_Abzugshaube room 99_MQTT2_DEVICE
attr 03_Abzugshaube setList off:noArg shellies/03_Abzugshaube/relay/0/command off\
on:noArg shellies/03_Abzugshaube/relay/0/command on\
x_update:noArg shellies/03_Abzugshaube/command update_fw\
x_mqttcom shellies/03_Abzugshaube/command $EVTPART1\
x_httpcom { X_PerformShellyHttpRequest($NAME,ReadingsVal($NAME,"ip","").",".$EVTPART1.",".ReadPassword($defs{$NAME})) }\
x_httpcom_login {StorePassword($defs{$NAME},$EVTPART1) }\
reboot:noArg { X_PerformShellyHttpRequest($NAME,ReadingsVal($NAME,"ip","").",".$EVENT.",".ReadPassword($defs{$NAME})) }\
status:noArg { X_PerformShellyHttpRequest($NAME,ReadingsVal($NAME,"ip","").",".$EVENT.",".ReadPassword($defs{$NAME})) }\
settings:noArg { X_PerformShellyHttpRequest($NAME,ReadingsVal($NAME,"ip","").",".$EVENT.",".ReadPassword($defs{$NAME})) }\
shelly:noArg { X_PerformShellyHttpRequest($NAME,ReadingsVal($NAME,"ip","").",".$EVENT.",".ReadPassword($defs{$NAME})) }\
attr 03_Abzugshaube userReadings StatusText { \
my $regex = "";;\
my $subst = "";;\
\
if (uc(ReadingsVal($NAME,"state","")) eq "OFF") {\
$regex = qr/(off|OFF)/mp;;\
$subst = 'aus';;}\
else {\
$regex = qr/(on|ON)/mp;;\
$subst = 'an';;}\
my $result = ReadingsVal($NAME,"state","") =~ s/$regex/$subst/rg;;\
return AttrVal($NAME,"alias","")." ist ".$result."!"}
attr 03_Abzugshaube webCmd on:off:settings:reboot
Alles anzeigen
Bitte melden, wenn du Vorschläge oder Fragen hast bzw. Fehler gefunden oder es strukturell anders machen würdest.
mdB um Nachsicht, ist halt nur 'mal so lösungsorientiert zusammengeworfen,
Gernot