[gelöst] Shelly Plus 1 - Anbindung

Begonnen von smoudo, 26 Dezember 2021, 15:58:21

Vorheriges Thema - Nächstes Thema

smoudo

Moin,

ich habe mit einem frisch installierten Shelly Plus 1 der mir die Außensteckdose schaltet Anbindungsprobleme. Das Shelly FHEM Modul scheint mit der neuen Generation nicht zu funktionieren. Schalten lässt es sich zwar, aber state ist immer auf Error, Passwortabfrage funktioniert nicht, etc.

Jetzt suche ich nach Alternativen Anbindemöglichkeiten.

-MQTT habe ich noch nicht am laufen, sollte aber aufgrund der Gerätezahl die mittlerweile da ist in betracht gezogen werden. (kostet halt einarbeitungszeit) wie sieht es da mit autocreate bei shelly 1 aus? Wiki ist an der stelle er rudimentär :)

-Andere Firnware flashen, ESPeasy habe ich auf etlichen ESP8266 am laufen. Ob es das für den ESP 32 gibt? Muss ich recharchieren! funktioniert auf vielen Geräten problemlos. (müsste ich das teil aber nochmal aus der Dose bauen) Zulassungstechnisch dürfte das auch eine dunkelgrauzone sein.

Wie habt Ihr das Problem gelöst?

Viele grüße

Matze

reibuehl

Hallo,

autocreate sollte mit dem FHEM internen MQTT2Server funktionieren. Im MQTT2_DEVICE gibt es auch schon ein Template für den Shelly Plus 1.

Gruß,
Reiner
Reiner.

vic

Guten Tag Community.
Ich habe zwei Shelly Plus 1 im Einsatz. Die Anbindung an MQTT2-Server funktionierte problemlos. Nach dem Anlernen an FHEM musste ich lediglich die Shellys kurz vom Netz trennen und wieder anschliessen. Somit zeigt das Shelly den Status Aktiv oder Nicht-Aktiv an (grüner oder roter Punkt). Das Shelly lässt sich schalten.
Einzig die Statusrückmeldung scheint nicht wie gewohnt zu klappen.

Habt ihr ähnliche Erfahrungen getätigt?

Anbei das Listing:


Internals:
   CFGFN      ./FHEM/fhem_020_Erdgeschoss.cfg
   CID        shellyplus1_a8032abcd5e8
   DEF        shellyplus1_a8032abcd5e8
   DEVICETOPIC shellyplus1-a8032abcd5e8
   FUUID      61bf3776-f33f-0f0b-0601-94a5f78e1f0867d0
   IODev      MQTT2
   LASTInputDev MQTT2
   MQTT2_CONN MQTT2_192.168.10.149_56587
   MQTT2_MSGCNT 3
   MQTT2_TIME 2021-12-27 02:01:12
   MSGCNT     3
   NAME       SH_AKT_149_AntiMuecken
   NR         227
   STATE      off
   TYPE       MQTT2_DEVICE
   JSONMAP:
     params_switch_0_aenergy_total aenergy_total
     params_switch_0_apower apower
     params_wifi_sta_ip ip
     temperature_tC temperature
     temperature_tF 0
   READINGS:
     2021-12-27 02:00:28   IODev           MQTT2
     2021-12-20 07:39:26   attrTemplateVersion 20211128
     2021-12-27 02:01:12   dst             shellyplus1-a8032abcd5e8/events
     2021-12-27 01:50:00   id              0
     2021-12-22 15:40:50   ip              192.168.10.149
     2021-12-27 02:01:12   method          NotifyStatus
     2021-12-27 02:01:12   online          true
     2021-12-22 15:39:15   params_events_1_cfg_rev 4
     2021-12-22 15:39:15   params_events_1_component wifi
     2021-12-22 15:39:15   params_events_1_event config_changed
     2021-12-22 15:39:15   params_events_1_restart_required false
     2021-12-22 15:39:15   params_events_1_ts 1640183955.63
     2021-12-27 02:01:12   params_mqtt_connected false
     2021-12-27 01:50:39   params_switch_0_id 0
     2021-12-27 01:00:23   params_switch_0_output false
     2021-12-27 01:00:23   params_switch_0_source MQTT
     2021-12-27 01:50:39   params_switch_0_temperature_tC 52.18
     2021-12-27 01:50:39   params_switch_0_temperature_tF 125.92
     2021-12-26 15:40:53   params_sys_available_updates_beta_version 0.9.2-beta2
     2021-12-27 02:01:12   params_ts       1640566802.86
     2021-12-22 15:40:50   params_wifi_rssi -55
     2021-12-22 15:40:50   params_wifi_ssid Lienta_01
     2021-12-22 15:40:50   params_wifi_status got ip
     2021-12-27 01:50:00   result_was_on   false
     2021-12-27 02:01:12   src             shellyplus1-a8032abcd5e8
     2021-12-27 01:50:00   state           off
Attributes:
   alias      Anti-Mücken 1
   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 = ReadingsVal($name,'switch_0_output','false') =~ m{false|off}?'off':'on';; $light = FW_makeImage($light);; 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>)}
   devicetopic shellyplus1-a8032abcd5e8
   event-on-change-reading .*
   group      Sommer
   icon       message_socket
   jsonMap    params_switch_0_aenergy_total:aenergy_total params_switch_0_apower:apower temperature_tC:temperature temperature_tF:0 params_wifi_sta_ip:ip
   model      shellyPlus_1
   readingList $DEVICETOPIC/online:.* online
  $DEVICETOPIC/events/rpc:.* { json2nameValue($EVENT,'',$JSONMAP) }
  $DEVICETOPIC/status/mqtt:.* { json2nameValue($EVENT, 'mqtt_', $JSONMAP) }
  $DEVICETOPIC/status/sys:.* { json2nameValue($EVENT, 'sys_', $JSONMAP) }
  $DEVICETOPIC/status/switch_0:.* { json2nameValue($EVENT, 'switch_0_', $JSONMAP) }
shellyplus1_a8032abcd5e8:fhem/rpc:.* { json2nameValue($EVENT) }
   room       MQTT2_DEVICE
   setList    toggle:noArg $DEVICETOPIC/rpc {"id":0,"src":"fhem","method":"Switch.Toggle","params": {"id":0}}
  off:noArg $DEVICETOPIC/rpc {"id":0,"src":"fhem","method":"Switch.Set","params": {"id":0,"on":false}}
  on:noArg $DEVICETOPIC/rpc {"id":0,"src":"fhem","method":"Switch.Set","params": {"id":0,"on":true}}
  on-for-timer $DEVICETOPIC/rpc {"id":0,"src":"fhem","method":"Switch.Set","params": {"id":0,"on":true,"toggle_after":$EVTPART1}}
  x_update:noArg $DEVICETOPIC/rpc {"id":0,"src":"fhem","method":"Shelly.Update","params": {"stage":"stable"}}
  x_reboot:noArg $DEVICETOPIC/rpc {"id":0,"src":"fhem","method":"Shelly.Reboot"}
   webCmd     :


Grüsse
Claudio
Raspberry Pi 4
RFXTRX 868MHz und 433MHz
FS20, Intertechno, Homematic, Shelly
MAX!-Cube, Philips HUE-Bridge

smoudo

probier mal im attribut devStateIcon
on:rc_GREEN:off off:rc_RED:on absent:rc_BLUE:off Error:rc_YELLOW:off

on, off, geht damit ohne probleme. ob absend oder Error im state angezeigt wird muss ich selber noch testen.
Optisch hab ich das ganze an meine Sonoffs angepasst. Die icons kannst du aber auch ändern.

Viele Grüße

Matze

Ps.: hab jetzt mal mttq2 aufgesetzt.  bislang problemlos.

vic

Vielen Dank für die rasche Antwort matze

Mit deinem devStateIcon-Eintrag funktioniert es. Leider kann wird dadurch jedoch leider der Anbindungszustand (online, offline fw-update) nicht angezeigt (Siehe Bilder).

Ich versuche schon seit einiger Zeit die Geheimnisse der devStateIcon-Parameter zu begreifen, leider ohne Erfolg. Anbei nochmals die Settings des devStateIcon - Dort wird der Anbindungszustand gezeigt, der Status (true|on oder false|off) jedoch leider nicht.


{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 = ReadingsVal($name,'switch_0_output','false') =~ m{false|off}?'off':'on';; $light = FW_makeImage($light);; 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>)}


Danke für eure Hilfe

Claudio
Raspberry Pi 4
RFXTRX 868MHz und 433MHz
FS20, Intertechno, Homematic, Shelly
MAX!-Cube, Philips HUE-Bridge

enno

{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 = '<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>"; "<div> $show <a href=\"/fhem?cmd.dummy=set $name toggle&XHR=1\">".FW_makeImage($light)."</a></div>" }

Zeigt das bei meinem Shelly 1 Plus so an.

Gruss
  Enno
Einfacher FHEM Anwender auf Intel®NUC

vic

Super vielen Dank für deine Antwort Enno

So wie ich es erkenne benützt du das Template das Shelly 1. Das funktioniert sehr gut wenn ich set shelly on oder set shelly off betätige.
Wenn ich mit dem Symbol direkt on oder off wähle wechselt das Icon wie im Bild und bleibt so erhalten.

Dabei habe ich festgestellt, dass wenn man set shelly on setzt das Reading params_switch_0_ouput false zurückgibt und umgekehrt. Der Aktor jedoch schaltet korrekt. Dies stört mich jedoch nicht solange das Shelly korrekt schaltet.


Vielen Dank für eure Hilfe
Raspberry Pi 4
RFXTRX 868MHz und 433MHz
FS20, Intertechno, Homematic, Shelly
MAX!-Cube, Philips HUE-Bridge

smoudo

@enno
wenn ich das so bei devstateicon hinterlege zeigt es bei mir nur "on" an. war das der original template code?
ich versucg das später mit meinen icons nochmal umzubauen. das mit dem zusäzlichen punkt bei softwareupdate finde ich sehr nice!

viele grüße

Matze

vic

Interessant... Bei mir zeigt es toggle an und bleibt so ... (wenn ich auf das icon klicke)
Raspberry Pi 4
RFXTRX 868MHz und 433MHz
FS20, Intertechno, Homematic, Shelly
MAX!-Cube, Philips HUE-Bridge

87insane

defmod MQTT2_shellyplus1pm_7c87ce657e74 MQTT2_DEVICE shellyplus1pm_7c87ce657e74
attr MQTT2_shellyplus1pm_7c87ce657e74 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 = ReadingsVal($name,'output','false') =~ m{false|off}?'off':'on';; $light = FW_makeImage($light);; my $cons = ReadingsNum($name,'apower',0);; my $total = round(ReadingsNum($name,'aenergy_total',0)/1000,1);; my $temp = ReadingsVal($name,'temperature','-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>Verbrauch: $cons W / Total: $total kwh / Temp: $temp °C</div>)}
attr MQTT2_shellyplus1pm_7c87ce657e74 devicetopic shellyplus1pm-7c87ce657e74
attr MQTT2_shellyplus1pm_7c87ce657e74 event-on-change-reading .*
attr MQTT2_shellyplus1pm_7c87ce657e74 genericDeviceType switch
attr MQTT2_shellyplus1pm_7c87ce657e74 jsonMap params_switch_0_aenergy_total:aenergy_total switch_0_apower:apower switch_0_temperature_tC:temperature switch_0_temperature_tF:0 params_wifi_sta_ip:ip
attr MQTT2_shellyplus1pm_7c87ce657e74 model shellyPlus_1pm
attr MQTT2_shellyplus1pm_7c87ce657e74 readingList $DEVICETOPIC/online:.* online\
  $DEVICETOPIC/events/rpc:.* { json2nameValue($EVENT,'',$JSONMAP) }\
  $DEVICETOPIC/status/mqtt:.* { json2nameValue($EVENT, 'mqtt_', $JSONMAP) }\
  $DEVICETOPIC/status/sys:.* { json2nameValue($EVENT, 'sys_', $JSONMAP) }\
  $DEVICETOPIC/status/switch_0:.* { json2nameValue($EVENT, 'switch_0_', $JSONMAP) }\
  fhem/rpc:.* { json2nameValue($EVENT,'rpc_',$JSONMAP) }
attr MQTT2_shellyplus1pm_7c87ce657e74 room MQTT2_DEVICE
attr MQTT2_shellyplus1pm_7c87ce657e74 setList toggle:noArg $DEVICETOPIC/rpc {"id":0,"src":"fhem","method":"Switch.Toggle","params": {"id":0}}\
  off:noArg $DEVICETOPIC/rpc {"id":0,"src":"fhem","method":"Switch.Set","params": {"id":0,"on":false}}\
  on:noArg $DEVICETOPIC/rpc {"id":0,"src":"fhem","method":"Switch.Set","params": {"id":0,"on":true}}\
  on-for-timer $DEVICETOPIC/rpc {"id":0,"src":"fhem","method":"Switch.Set","params": {"id":0,"on":true,"toggle_after":$EVTPART1}}\
  x_update:noArg $DEVICETOPIC/rpc {"id":0,"src":"fhem","method":"Shelly.Update","params": {"stage":"stable"}}\
  x_reboot:noArg $DEVICETOPIC/rpc {"id":0,"src":"fhem","method":"Shelly.Reboot"}

setstate MQTT2_shellyplus1pm_7c87ce657e74 toggle
setstate MQTT2_shellyplus1pm_7c87ce657e74 2021-12-24 11:42:44 aenergy_total 0.000
setstate MQTT2_shellyplus1pm_7c87ce657e74 2021-12-24 11:42:00 apower 0.0
setstate MQTT2_shellyplus1pm_7c87ce657e74 2021-12-24 11:43:38 dst shellyplus1pm-7c87ce657e74/events


Hey zusammen. Ich hab das nur überflogen. Aber so geht alles. Strittig ist noch das fhem/rpc reading. Aber das steht alles in dem Shelly Template Thread. Der von mir grade kopierte shelly ist aktuell nicht am Strom. Also nicht wundern.

Gruß,
87insane

smoudo

Das ist wie oben beschrieben. Das zeigt bei mir zwar die punkte farbig an, beim toggle ändert sich aber das icon nicht. Schaltvorgang wird aber durchgeführt.
kann man das reading "online" irgendwie als wert present oder absent in state bekommen? bzw. ein presence reading erzeugen? Eine Anzeige ob das teil offline oder online ist, währe schon fein.
Diese Details machen mich noch Irre!

Viele Grüße

Matze

vic

Danke für den Beitrag 87insane

Leider funktionieren die Icons, wie bereits von Matze beschrieben, nicht ordnungsgemäss. Sie bleiben immer auf off egal wie man schaltet.
Da kommt der Einsatz des Shelly 1-Templates (Post von Enno) dem gewünschten Ergebnis näher. Einziger Nachteil dort - man kann nicht mittels Klick auf Icon schalten sondern mit den Befehlen set Shelly on und set Shelly off (also kein webCmd :    )

Grüsse
Claudio
Raspberry Pi 4
RFXTRX 868MHz und 433MHz
FS20, Intertechno, Homematic, Shelly
MAX!-Cube, Philips HUE-Bridge

87insane

Habt ihr auch die jsonmap angepasst ? Bei mir schaltet so alles und wird auch als online angezeigt. Wie sind die mqtt Einstellungen im shelly?

Gruß,
87insane

vic

Die jsonmap wurde angepasst. Leider ohne Erfolg. Ich verwende das Shelly Plus 1 (nicht 1pm).

Es funktioniert ja eigentlich alles. Nur das Icon (devStateIcon) will einfach nicht umschalten  >:(
Raspberry Pi 4
RFXTRX 868MHz und 433MHz
FS20, Intertechno, Homematic, Shelly
MAX!-Cube, Philips HUE-Bridge

87insane

Also der Punkt ist abhängig vom reading Inhalt. Setz mal bitte noch generic... Im shelly auf on. Das ist normal auch an. Danach sollte es rein laufen. Wenn nicht. Poste bitte nochmal deine readingslist. Es muss ja einen unterschied zu meiner geben.

Oder am besten ein aktuelles RAW. Es ist egal ob pm oder nicht. Der eine kann nur mehr. Aber online/offline kommt bei beiden via mqtt. Ich bin gespannt...

Gruß,
87insane