Shelly Pro - Serie anbinden

Begonnen von vic, 25 Januar 2023, 17:21:49

Vorheriges Thema - Nächstes Thema

vic

Liebe Gemeinde

Es ist nun einige Monate her, dass ich mit den Versuchen Shellies in FHEM mittels mqtt einzubinden begonnen hatte.
Sämtliche Einträge im Forum, welche ich gefunden habe, haben leider nicht gefruchtet.
Unterdessen bin ich absolut frustriert.

Aus diesem Grund eröffne ich dieses Thema mit der bitte nur Shelly Pro (siehe Anhang) Beiträge einzustellen.
Ich möchte gerne die folgende Modelle in Betrieb nehmen:
- Shelly Pro 1
- Shelly Pro 2
- Shelly Pro 3
- Shelly Pro 4 (scheint soweit zu funktionieren)

Ich bin bereit für die Person die mir helfen möchte und kann die Anschaffung der Komponenten finanziell zu übernehmen.

Vielen Dank

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

Beta-User

Sind das nicht "einfach" Geräte mit 2nd Gen.-Kommunikation? Dann müßten eigentlich die entsprechenden aktuellen "plus"-templates passen...
Server: HP-elitedesk@Debian 12, aktuelles FHEM@ConfigDB | CUL_HM (VCCU) | MQTT2: MiLight@ESP-GW, BT@OpenMQTTGw | MySensors: seriell, v.a. 2.3.1@RS485 | ZWave | ZigBee@deCONZ | SIGNALduino | MapleCUN | RHASSPY
svn: u.a MySensors, Weekday-&RandomTimer, Twilight,  div. attrTemplate-files

KernSani

Ich frage mal ganz dumm... DIe Pro Serie kann doch - genauso wie die nicht-Pros - MQTT. Wo konkret sind also die Schwierigkeiten die Geräte in FHEM einzubinden?

RasPi: RFXTRX, HM, zigbee2mqtt, mySensors, JeeLink, miLight, squeezbox, Alexa, Siri, ...

Beta-User

Zitat von: KernSani am 25 Januar 2023, 17:34:07
Ich frage mal ganz dumm... DIe Pro Serie kann doch - genauso wie die nicht-Pros - MQTT. Wo konkret sind also die Schwierigkeiten die Geräte in FHEM einzubinden?
Du hast vermutlich noch nie gesehen, wie speziell das ist, was da via MQTT bei den 2nd Gen.-Geräten kommt...

Beschreibung siehe https://shelly-api-docs.shelly.cloud/gen2/ComponentsAndServices/Mqtt/

Wie man damit umgehen kann (als Vorschlag) ist in der mqtt2.template-File zu finden ;) .
Server: HP-elitedesk@Debian 12, aktuelles FHEM@ConfigDB | CUL_HM (VCCU) | MQTT2: MiLight@ESP-GW, BT@OpenMQTTGw | MySensors: seriell, v.a. 2.3.1@RS485 | ZWave | ZigBee@deCONZ | SIGNALduino | MapleCUN | RHASSPY
svn: u.a MySensors, Weekday-&RandomTimer, Twilight,  div. attrTemplate-files

Ralli

Du kannst und solltest dich anhand der Templates durchwurschteln, um die grundsätzliche Struktur etc. zu verstehen - habe ich auch gemacht.

Es gibt auch mehrere Wege, insbesondere Mehrkanal-Geräte einzubinden. Letztendlich scheint Best-Practice zu sein, auch weitere Kanäle eines Geräte als eigenes MQTT2-Device zu definieren. Insbesondere ist wichtig, welches Topic du in den Shellys definierst; ich habe hier als Präfix nicht "shellies" sonder "Shelly" und dann den Shelly-Namen, den ich selbst vergeben habe.

Als Beispiel hänge ich dir von einem Pro 3 den Kanal 0 an:


defmod GAR_Deckenlicht MQTT2_DEVICE GAR_Shelly
attr GAR_Deckenlicht IODev MQTT2_Client_energy_fhem
attr GAR_Deckenlicht alias Deckenlicht Garage
attr GAR_Deckenlicht comment http://192.168.7.41/#/switch/0/overview
attr GAR_Deckenlicht devicetopic Shelly/GAR_Shelly
attr GAR_Deckenlicht event-on-change-reading .*
attr GAR_Deckenlicht genericDeviceType light
attr GAR_Deckenlicht group Licht
attr GAR_Deckenlicht homebridgeMapping On=state
attr GAR_Deckenlicht icon light_wall_2
attr GAR_Deckenlicht jsonMap switch_state:state\
switch_voltage:voltage\
switch_current:current\
switch_apower:power\
switch_temperature_tC:temperature\
switch_temperature_tF:0\
switch_source:source\
switch_id:0\
switch_dst:0\
switch_method:0\
switch_params_switch_0_id:0\
switch_params_switch_0_source:source\
switch_params_switch_0_state:state\
switch_params_switch_0_temperature_tC:temperature\
switch_params_switch_0_temperature_tFreq_dst:0\
req_dst:0\
req_id:0\
req_method:0\
req_params_id:0\
req_result_aenergy_by_minute_1:switch_aenergy_by_minute_1\
req_result_aenergy_by_minute_2:switch_aenergy_by_minute_2\
req_result_aenergy_by_minute_3:switch_aenergy_by_minute_3\
req_result_aenergy_minute_ts:switch_aenergy_minute_ts\
req_result_aenergy_total:switch_aenergy_total\
req_result_apower:power\
req_result_current:current\
req_result_id:0\
req_result_state:state\
req_result_pf:0\
req_result_source:source\
req_result_temperature_tC:temperature\
req_result_temperature_tF:0\
req_result_voltage:voltage\
req_src:0
attr GAR_Deckenlicht readingList $DEVICETOPIC/online:.* online\
$DEVICETOPIC/status/sys:.* { json2nameValue($EVENT) }\
$DEVICETOPIC/status/cloud:.* { json2nameValue($EVENT) }\
$DEVICETOPIC/status/mqtt:.* { json2nameValue($EVENT) }\
$DEVICETOPIC/events/rpc:.* { return if $EVENT !~ m{switch:0};; $EVENT =~ s/"output":true/"state":"on"/g;; $EVENT =~ s/"output":false/"state":"off"/g;; json2nameValue($EVENT,'switch_',$JSONMAP) }\
$DEVICETOPIC/status/switch.0:.* { $EVENT =~ s/"output":true/"state":"on"/g;; $EVENT =~ s/"output":false/"state":"off"/g;; json2nameValue($EVENT, 'switch_', $JSONMAP) }\
$DEVICETOPIC/rpc:.* { return if $EVENT !~ m{\"result\":\{\"id\":0};; $EVENT =~ s/"output":true/"state":"on"/g;; $EVENT =~ s/"output":false/"state":"off"/g;; json2nameValue($EVENT, 'req_', $JSONMAP)}\

attr GAR_Deckenlicht room Garage
attr GAR_Deckenlicht setList toggle:noArg $DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Switch.Toggle","params": {"id":0}}\
off:noArg $DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Switch.Set","params": {"id":0,"on":false}}\
on:noArg $DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Switch.Set","params": {"id":0,"on":true}}\
on-for-timer $DEVICETOPIC/rpc {"id":0,"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}}\
status-request:noArg $DEVICETOPIC/rpc {"id":1,"src":"$DEVICETOPIC","method":"Switch.GetStatus","params": {"id":0}}
attr GAR_Deckenlicht siriName Deckenleuchte
attr GAR_Deckenlicht webCmd state
attr GAR_Deckenlicht widgetOverride state:uzsuToggle,on,off


Das ist jetzt nicht alles genau wie im Template und kann auch sicherlich noch vereinfacht werden, ist aber für meine Integration genau passend.

Hier der dazu passende Kanal 1:


defmod GAR_Aussenlicht MQTT2_DEVICE
attr GAR_Aussenlicht IODev MQTT2_Client_energy_fhem
attr GAR_Aussenlicht alexaName Wandlicht Garage
attr GAR_Aussenlicht alias Wandlicht Garage
attr GAR_Aussenlicht comment http://192.168.7.41/#/switch/1/overview
attr GAR_Aussenlicht devicetopic Shelly/GAR_Shelly
attr GAR_Aussenlicht event-on-change-reading .*
attr GAR_Aussenlicht event-on-update-reading switch_apower,switch_current,switch_energy,switch_voltage,temperature
attr GAR_Aussenlicht genericDeviceType light
attr GAR_Aussenlicht group Licht
attr GAR_Aussenlicht homebridgeMapping On=state
attr GAR_Aussenlicht icon building_carport_light
attr GAR_Aussenlicht jsonMap switch_state:state\
switch_voltage:voltage\
switch_current:current\
switch_apower:power\
switch_temperature_tC:temperature\
switch_temperature_tF:0\
switch_source:source\
switch_dst:0\
switch_method:0\
switch_id:0\
switch_params_switch_1_id:0\
switch_params_switch_1_source:source\
switch_params_switch_1_state:state\
switch_params_switch_1_temperature_tC:temperature\
switch_params_switch_1_temperature_tFreq_dst:0\
req_dst:0\
req_id:0\
req_method:0\
req_params_id:0\
req_result_aenergy_by_minute_1:switch_aenergy_by_minute_1\
req_result_aenergy_by_minute_2:switch_aenergy_by_minute_2\
req_result_aenergy_by_minute_3:switch_aenergy_by_minute_3\
req_result_aenergy_minute_ts:switch_aenergy_minute_ts\
req_result_aenergy_total:switch_aenergy_total\
req_result_apower:power\
req_result_current:current\
req_result_id:0\
req_result_state:state\
req_result_pf:0\
req_result_source:source\
req_result_temperature_tC:temperature\
req_result_temperature_tF:0\
req_result_voltage:voltage\
req_src:0
attr GAR_Aussenlicht readingList $DEVICETOPIC/online:.* online\
$DEVICETOPIC/events/rpc:.* { return if $EVENT !~ m{switch:1};; $EVENT =~ s/"output":true/"state":"on"/g;; $EVENT =~ s/"output":false/"state":"off"/g;; json2nameValue($EVENT,'switch_',$JSONMAP) }\
$DEVICETOPIC/status/switch.1:.* { $EVENT =~ s/"output":true/"state":"on"/g;; $EVENT =~ s/"output":false/"state":"off"/g;; json2nameValue($EVENT, 'switch_', $JSONMAP) }\
$DEVICETOPIC/rpc:.* { return if $EVENT !~ m{\"result\":\{\"id\":1};; $EVENT =~ s/"output":true/"state":"on"/g;; $EVENT =~ s/"output":false/"state":"off"/g;; json2nameValue($EVENT, 'req_', $JSONMAP)}
attr GAR_Aussenlicht room Garage,Homekit
attr GAR_Aussenlicht setList toggle:noArg $DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Switch.Toggle","params": {"id":1}}\
off:noArg $DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Switch.Set","params": {"id":1,"on":false}}\
on:noArg $DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Switch.Set","params": {"id":1,"on":true}}\
on-for-timer $DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Switch.Set","params": {"id":1,"on":true,"toggle_after":$EVTPART1}}\
off-for-timer $DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Switch.Set","params": {"id":1,"on":false,"toggle_after":$EVTPART1}}\
status-request:noArg $DEVICETOPIC/rpc {"id":1,"src":"$DEVICETOPIC","method":"Switch.GetStatus","params": {"id":1}}
attr GAR_Aussenlicht siriName Wandleuchte
attr GAR_Aussenlicht webCmd state
attr GAR_Aussenlicht widgetOverride state:uzsuToggle,on,off


Und hier der dazu passende Kanal 2:


defmod GAR_Aussensteckdose MQTT2_DEVICE
attr GAR_Aussensteckdose IODev MQTT2_Client_energy_fhem
attr GAR_Aussensteckdose alexaName Außensteckdosen Garage
attr GAR_Aussensteckdose alias Außensteckdosen Garage
attr GAR_Aussensteckdose comment http://192.168.7.41/#/switch/2/overview
attr GAR_Aussensteckdose devicetopic Shelly/GAR_Shelly
attr GAR_Aussensteckdose event-on-change-reading .*
attr GAR_Aussensteckdose event-on-update-reading switch_apower,switch_current,switch_energy,switch_voltage,temperature
attr GAR_Aussensteckdose genericDeviceType outlet
attr GAR_Aussensteckdose group Steckdosen
attr GAR_Aussensteckdose homebridgeMapping On=state
attr GAR_Aussensteckdose icon building_carport_light
attr GAR_Aussensteckdose jsonMap switch_state:state\
switch_voltage:voltage\
switch_current:current\
switch_apower:power\
switch_temperature_tC:temperature\
switch_temperature_tF:0\
switch_source:source\
switch_dst:0\
switch_method:0\
switch_params_switch_2_id:0\
switch_params_switch_2_source:source\
switch_params_switch_2_state:state\
switch_params_switch_2_temperature_tC:temperature\
switch_params_switch_2_temperature_tFreq_dst:0\
switch_id:0\
req_id:0\
req_method:0\
req_params_id:0\
req_result_aenergy_by_minute_1:switch_aenergy_by_minute_1\
req_result_aenergy_by_minute_2:switch_aenergy_by_minute_2\
req_result_aenergy_by_minute_3:switch_aenergy_by_minute_3\
req_result_aenergy_minute_ts:switch_aenergy_minute_ts\
req_result_aenergy_total:switch_aenergy_total\
req_result_apower:power\
req_result_current:current\
req_result_id:0\
req_result_state:state\
req_result_pf:0\
req_result_source:source\
req_result_temperature_tC:temperature\
req_result_temperature_tF:0\
req_result_voltage:voltage\
req_src:0
attr GAR_Aussensteckdose readingList $DEVICETOPIC/online:.* online\
$DEVICETOPIC/events/rpc:.* { return if $EVENT !~ m{switch:2};; $EVENT =~ s/"output":true/"state":"on"/g;; $EVENT =~ s/"output":false/"state":"off"/g;; json2nameValue($EVENT,'switch_',$JSONMAP) }\
$DEVICETOPIC/status/switch.2:.* { $EVENT =~ s/"output":true/"state":"on"/g;; $EVENT =~ s/"output":false/"state":"off"/g;; json2nameValue($EVENT, 'switch_', $JSONMAP) }\
$DEVICETOPIC/rpc:.* { return if $EVENT !~ m{\"result\":\{\"id\":2};; $EVENT =~ s/"output":true/"state":"on"/g;; $EVENT =~ s/"output":false/"state":"off"/g;; json2nameValue($EVENT, 'req_', $JSONMAP)}
attr GAR_Aussensteckdose room Garage,Homekit
attr GAR_Aussensteckdose setList toggle:noArg $DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Switch.Toggle","params": {"id":2}}\
off:noArg $DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Switch.Set","params": {"id":2,"on":false}}\
on:noArg $DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Switch.Set","params": {"id":2,"on":true}}\
on-for-timer $DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Switch.Set","params": {"id":2,"on":true,"toggle_after":$EVTPART1}}\
off-for-timer $DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Switch.Set","params": {"id":2,"on":false,"toggle_after":$EVTPART1}}\
status-request:noArg $DEVICETOPIC/rpc {"id":1,"src":"$DEVICETOPIC","method":"Switch.GetStatus","params": {"id":2}}
attr GAR_Aussensteckdose siriName Außensteckdosen vorne
attr GAR_Aussensteckdose webCmd state
attr GAR_Aussensteckdose widgetOverride state:uzsuToggle,on,off
Gruß,
Ralli

Proxmox 8.1 Cluster mit HP ED800G2i7, Intel NUC11TNHi7+NUC7i5BNH, virtualisiertes fhem 6.3 dev, virtualisierte RaspberryMatic (3.75.6.20240316) mit HB-RF-ETH 1.3.0 / RPI-RF-MOD, HM-LAN-GW (1.1.5) und HMW-GW, FRITZBOX 7490 (07.57), FBDECT, Siri und Alexa

JoWiemann

Hallo,

mal ne ganz blöde Frage. Warum benutzt Du nicht das Shelly Modul? https://forum.fhem.de/index.php?topic=110714.0

Grüße Jörg
Jörg Wiemann

Slave: RPi B+ mit 512 MB, COC (868 MHz), CUL V3 (433.92MHz SlowRF); FHEMduino, Aktuelles FHEM

Master: CubieTruck; Debian; Aktuelles FHEM

Ralli

... damit funktioniert bspw. der Pro 3 nicht. Und ich persönlich habe mich daher für den Weg, alles über MQTT2 anzubinden, entschieden; dies hat auch den Vorteil, dass ich noch andere Systeme, die MQTT verstehen, ebenfalls anbinden konnte.
Gruß,
Ralli

Proxmox 8.1 Cluster mit HP ED800G2i7, Intel NUC11TNHi7+NUC7i5BNH, virtualisiertes fhem 6.3 dev, virtualisierte RaspberryMatic (3.75.6.20240316) mit HB-RF-ETH 1.3.0 / RPI-RF-MOD, HM-LAN-GW (1.1.5) und HMW-GW, FRITZBOX 7490 (07.57), FBDECT, Siri und Alexa

vic

#7
Vielen Dank für eure Hilfe und vor allem auch für das Listing @Ralli.

Entschuldigt wenn ich so spät antworte. Wir hatten Semesterabschluss und ich war mit Prüfungskorrekturen eingedeckt.
Unterdessen habe ich auch rausgefunden, dass der ShellyPro3 gar nicht funktioniert. Der wird retourniert.
Mit dem ShellyPro1 konnte ich unterdessen die gewünschten Parameter einstellen und er funktioniert einwandfrei. Wow.. bin echt erleichtert.

Beim ShellyPro2 habe ich ein Problem mit dem ersten Kanal. Er shaltet zwar jedoch bekomme ich nicht die korrekte Rückmeldung. Wenn ich das Listing anschaue meldet er mir STATE set_off (oder set_on) und nicht off oder on.
Vermutlich ist es etwas kleines aber ich stehe schon wieder an.

Anbei die Informationen:
Internals:

   CID        shellypro2_30c6f78120fc
   DEF        shellypro2_30c6f78120fc
   FUUID      63f3963e-f33f-0f0b-7a51-6f48862df72b0045
   IODev      MQTT2
   LASTInputDev MQTT2
   MQTT2_CONN MQTT2_192.168.11.157_54818
   MQTT2_MSGCNT 30
   MQTT2_TIME 2023-02-20 16:55:44
   MSGCNT     30
   NAME       MQTT2_shellypro2_30c6f78120fc
   NR         3194
   STATE      set_off
   TYPE       MQTT2_DEVICE
   eventCount 28
   JSONMAP:
     params_switch_0_temperature_tC temperature
     params_switch_0_temperature_tF 0
     params_wifi_sta_ip ip
     req_result_in_mode in_mode
     switch_state state
     switch_temperature_tC temperature
     switch_temperature_tF 0


READINGS:

     2023-02-20 16:48:15   IODev           MQTT2
     2023-02-20 16:45:47   associatedWith  MQTT2_shellypro2_30c6f78120fc_CH2,MQTT2_shellypro2_30c6f78120fc_CH3,MQTT2_shellypro2_30c6f78120fc_CH4
     2023-02-20 16:45:56   attrTemplateVersion 20220304
     2023-02-20 16:55:44   dst             shellypro2-30c6f78120fc/events
     2023-02-20 16:55:44   method          NotifyStatus
     2023-02-20 16:48:31   online          true
     2023-02-20 16:45:57   params_events_1_component sys
     2023-02-20 16:45:57   params_events_1_event scheduled_restart
     2023-02-20 16:45:57   params_events_1_time_ms 997
     2023-02-20 16:45:57   params_events_1_ts 1676907957.39
     2023-02-20 16:48:31   params_mqtt_connected true
     2023-02-20 16:55:44   params_switch_0_id 0
     2023-02-20 16:55:44   params_switch_0_output false
     2023-02-20 16:55:44   params_switch_0_source MQTT
     2023-02-20 16:48:35   params_switch_1_id 1
     2023-02-20 16:48:35   params_switch_1_output false
     2023-02-20 16:48:35   params_switch_1_source MQTT
     2023-02-20 16:46:12   params_sys_available_updates_stable_version 0.13.0
     2023-02-20 16:55:44   params_ts       1676908544.39
     2023-02-20 16:55:44   src             shellypro2-30c6f78120fc
     2023-02-20 16:55:43   state           set_off
     2023-02-20 16:45:56   x_reboot        set


Attributes:

   comment    Channel 1 for MQTT2_shellypro2_30c6f78120fc, see also MQTT2_shellypro2_30c6f78120fc_CH2, MQTT2_shellypro2_30c6f78120fc_CH3 and MQTT2_shellypro2_30c6f78120fc_CH4
   devStateIcon {my $onl = ReadingsVal($name,'online','false') eq 'false'?'10px-kreis-rot':'10px-kreis-gruen'; $onl = FW_makeImage($onl); my $light = FW_makeImage(ReadingsVal($name,'state','off')); my $temp = ReadingsVal($name,'temperature','-100'); my $ip = ReadingsVal($name,'ip','none'); my $reb = ReadingsVal($name,'sys_restart_required','false') eq 'true'?'<a href="/fhem?cmd.dummy=set '.$name.' x_reboot&XHR=1"> ... Notwendigen Reboot durchführen</a>':''; qq(<a href="http://$ip" target="_blank">${onl}</a><a href="/fhem?cmd.dummy=set $name toggle&XHR=1">${light}</a>$reb<div>Temp: $temp °C</div>)}
   devicetopic shellypro2-30c6f78120fc
   getList    in_mode:noArg in_mode $DEVICETOPIC/rpc {"id": 1,"src":"$DEVICETOPIC", "method": "Switch.GetConfig", "params": {"id": 0}}
   group      Versuchsschaltungen
   icon       message_socket
   jsonMap    switch_state:state switch_temperature_tC:temperature switch_temperature_tF:0 params_wifi_sta_ip:ip params_switch_0_temperature_tC:temperature params_switch_0_temperature_tF:0 req_result_in_mode:in_mode
   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:.* { $EVENT =~ s/"output":true/"state":"on"/g; $EVENT =~ s/"output":false/"state":"off"/g; json2nameValue($EVENT, 'switch_', $JSONMAP) }
  $DEVICETOPIC/status/cloud:.* {}
  $DEVICETOPIC/rpc:.* { json2nameValue($EVENT, 'req_', $JSONMAP, 'in_mode')}
  $DEVICETOPIC/status/input_0:.* { json2nameValue($EVENT, 'input_', $JSONMAP) }
  fhem2shelly/rpc:.* {}
shellypro2_30c6f78120fc:shellypro2-30c6f78120fc/online:.* online
shellypro2_30c6f78120fc:shellypro2-30c6f78120fc/status/mqtt:.* { json2nameValue($EVENT) }
shellypro2_30c6f78120fc:shellypro2-30c6f78120fc/events/rpc:.* { json2nameValue($EVENT) }
shellypro2_30c6f78120fc:shellypro2-30c6f78120fc/status/sys:.* { json2nameValue($EVENT) }
shellypro2_30c6f78120fc:shellypro2-30c6f78120fc/status/switch_0:.* { json2nameValue($EVENT) }
   room       MQTT2_DEVICE
   setList    toggle:noArg $DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Switch.Toggle","params": {"id":0}}
  off:noArg $DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Switch.Set","params": {"id":0,"on":false}}
  on:noArg $DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Switch.Set","params": {"id":0,"on":true}}
  on-for-timer $DEVICETOPIC/rpc {"id":0,"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}}
  in_mode:toggle,flip,detached {fhem("sleep 0.2; get $NAME in_mode"); my $val = $EVTPART1 ne 'toggle' ? $EVTPART1 : ReadingsVal($NAME,'in_mode','flip') eq 'flip' ? 'detached':'flip'; qq($DEVICETOPIC/rpc {"id":1,"src":"fhem2shelly","method":"Switch.SetConfig","params": {"id":0, "config": {"in_mode": "$val"}}})}
  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"}
  x_eco:true,false $DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Sys.SetConfig","params": {"config": {"device": {"eco_mode": $EVTPART1}}}}
   setStateList on off toggle on-for-timer off-for-timer
   webCmd     :


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

Beta-User

#8
..irgendwas ist da sehr komisch...: Die automatisch ergänzten Teile der readingList dürfte es eigentlich nicht geben (die mit CID: vorne).
Irgendwas verhindert, dass das korrekt ausgewertet wird, daher bleiben die Readings auf den set_-Anweisungen und die Rückmeldung wird nicht korrekt ausgewertet.

Auf die Schnelle noch keine Idee. FHEM ist aktuell? (Wenn ja, sollte sich Rudi das ggf. mal ansehen).

EDIT: Rudi schreibt hier, dass ggf. "deviceTopic" falsch wäre, da war aber - anders als hier - die CID mit drin: https://forum.fhem.de/index.php/topic,132263.msg1264284.html#msg1264284
Server: HP-elitedesk@Debian 12, aktuelles FHEM@ConfigDB | CUL_HM (VCCU) | MQTT2: MiLight@ESP-GW, BT@OpenMQTTGw | MySensors: seriell, v.a. 2.3.1@RS485 | ZWave | ZigBee@deCONZ | SIGNALduino | MapleCUN | RHASSPY
svn: u.a MySensors, Weekday-&RandomTimer, Twilight,  div. attrTemplate-files

vic

Vielen Dank für eure gross Unterstützung.

Unterdessen konnte ich funktionierende Konfigurationen erstellen.
Folgende Parameter sind für mich sinnvoll:
event-on-change-reading state:on,state:off (somit erhalte ich nur die Symbole, die ich möchte)
devStateIcon (Dort möchte ich gerne ein individuelles Icon benützen z.B. sani_water_hot@red sani_water_hot@green)

Ich stelle mal meine Auflistung ein... vielleicht findet ihr Optimierungsmöglichkeiten für die ich natürlich sehr dankbar bin.

# ****************** ShellyPro-Templates ******************

# ****************** Shelly Pro 1 - Start ******************
define DEVICE_Pro1 MQTT2_DEVICE shellypro1_DEVICE_Pro1_Serial
attr DEVICE_Pro1 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') eq 'off'?'FS20.off':'FS20.on';; $light = FW_makeImage($light); 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>" }
attr DEVICE_Pro1 devicetopic shellypro1-DEVICE_Pro1_Serial
attr DEVICE_Pro1 event-on-change-reading state:on,state:off

attr DEVICE_Pro1 getList in_mode:noArg in_mode $DEVICETOPIC/rpc {"id": 1,"src":"$DEVICETOPIC", "method": "Switch.GetConfig", "params": {"id": 0}}
attr DEVICE_Pro1 group Versuchsschaltungen
attr DEVICE_Pro1 icon message_socket
attr DEVICE_Pro1 jsonMap switch_state:state switch_temperature_tC:temperature switch_temperature_tF:0 params_wifi_sta_ip:ip params_switch_0_temperature_tC:temperature params_switch_0_temperature_tF:0 req_result_in_mode:in_mode
attr DEVICE_Pro1 model shellyPro_1
attr DEVICE_Pro1 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:.* { $EVENT =~ s/"output":true/"state":"on"/g;; $EVENT =~ s/"output":false/"state":"off"/g;; json2nameValue($EVENT, 'switch_', $JSONMAP) }\
  $DEVICETOPIC/status/cloud:.* {}\
  $DEVICETOPIC/rpc:.* { json2nameValue($EVENT, 'req_', $JSONMAP, 'in_mode')}\
  $DEVICETOPIC/status/input_0:.* { json2nameValue($EVENT, 'input_', $JSONMAP) }\
  fhem2shelly/rpc:.* {}\
shellypro1_DEVICE_Pro1_Serial:shellypro1-DEVICE_Pro1_Serial/online:.* online\
shellypro1_DEVICE_Pro1_Serial:shellypro1-DEVICE_Pro1_Serial/status/mqtt:.* { json2nameValue($EVENT) }\
shellypro1_DEVICE_Pro1_Serial:shellypro1-DEVICE_Pro1_Serial/events/rpc:.* { json2nameValue($EVENT) }\
shellypro1_DEVICE_Pro1_Serial:shellypro1-DEVICE_Pro1_Serial/status/sys:.* { json2nameValue($EVENT) }\
shellypro1_DEVICE_Pro1_Serial:shellypro1-DEVICE_Pro1_Serial/status/switch_0:.* { json2nameValue($EVENT) }
attr DEVICE_Pro1 room MQTT2_DEVICE
attr DEVICE_Pro1 setList toggle:noArg $DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Switch.Toggle","params": {"id":0}}\
  off:noArg $DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Switch.Set","params": {"id":0,"on":false}}\
  on:noArg $DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Switch.Set","params": {"id":0,"on":true}}\
  on-for-timer $DEVICETOPIC/rpc {"id":0,"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}}\
  in_mode:toggle,flip,detached {fhem("sleep 0.2;; get $NAME in_mode");; my $val = $EVTPART1 ne 'toggle' ? $EVTPART1 : ReadingsVal($NAME,'in_mode','flip') eq 'flip' ? 'detached':'flip';; qq($DEVICETOPIC/rpc {"id":1,"src":"fhem2shelly","method":"Switch.SetConfig","params": {"id":0, "config": {"in_mode": "$val"}}})}\
  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"}\
  x_eco:true,false $DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Sys.SetConfig","params": {"config": {"device": {"eco_mode": $EVTPART1}}}}
attr DEVICE_Pro1 setStateList on off toggle on-for-timer off-for-timer
attr DEVICE_Pro1 webCmd :

define FileLog_DEVICE_Pro1 FileLog ./log/DEVICE_Pro1-%Y.log DEVICE_Pro1
attr FileLog_DEVICE_Pro1 logtype text
attr FileLog_DEVICE_Pro1 room MQTT2_DEVICE
# ****************** Shelly Pro 1 - Ende ******************

# ****************** Shelly Pro 2 - Start ******************
# ------------------ Shelly Pro 2 - Kanal 1 - Start ------------------
define DEVICE_Pro2 MQTT2_DEVICE DEVICE_Pro2_Serial
attr DEVICE_Pro2 IODev MQTT2
attr DEVICE_Pro2 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') eq 'off'?'FS20.off':'FS20.on';; $light = FW_makeImage($light); 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>" }
attr DEVICE_Pro2 devicetopic shellypro2-DEVICE_Pro2_Serial
attr DEVICE_Pro2 event-on-change-reading state:on,state:off
attr DEVICE_Pro2 group Versuchsschaltungen
attr DEVICE_Pro2 jsonMap\
switch_state:state\
switch_voltage:voltage\
switch_current:current\
switch_apower:power\
switch_temperature_tC:temperature\
switch_temperature_tF:0\
switch_source:source\
switch_id:0\
switch_dst:0\
switch_method:0\
switch_params_switch_0_id:0\
switch_params_switch_0_source:source\
switch_params_switch_0_state:state\
switch_params_switch_0_temperature_tC:temperature\
switch_params_switch_0_temperature_tFreq_dst:0\
req_dst:0\
req_id:0\
req_method:0\
req_params_id:0\
req_result_aenergy_by_minute_1:switch_aenergy_by_minute_1\
req_result_aenergy_by_minute_2:switch_aenergy_by_minute_2\
req_result_aenergy_by_minute_3:switch_aenergy_by_minute_3\
req_result_aenergy_minute_ts:switch_aenergy_minute_ts\
req_result_aenergy_total:switch_aenergy_total\
req_result_apower:power\
req_result_current:current\
req_result_id:0\
req_result_state:state\
req_result_pf:0\
req_result_source:source\
req_result_temperature_tC:temperature\
req_result_temperature_tF:0\
req_result_voltage:voltage\
req_src:0
attr DEVICE_Pro2 readingList $DEVICETOPIC/online:.* online\
$DEVICETOPIC/status/sys:.* { json2nameValue($EVENT) }\
$DEVICETOPIC/status/cloud:.* { json2nameValue($EVENT) }\
$DEVICETOPIC/status/mqtt:.* { json2nameValue($EVENT) }\
$DEVICETOPIC/events/rpc:.* { return if $EVENT !~ m{switch:0};; $EVENT =~ s/"output":true/"state":"on"/g;; $EVENT =~ s/"output":false/"state":"off"/g;; json2nameValue($EVENT,'switch_',$JSONMAP) }\
$DEVICETOPIC/status/switch.0:.* { $EVENT =~ s/"output":true/"state":"on"/g;; $EVENT =~ s/"output":false/"state":"off"/g;; json2nameValue($EVENT, 'switch_', $JSONMAP) }\
$DEVICETOPIC/rpc:.* { return if $EVENT !~ m{\"result\":\{\"id\":0};; $EVENT =~ s/"output":true/"state":"on"/g;; $EVENT =~ s/"output":false/"state":"off"/g;; json2nameValue($EVENT, 'req_', $JSONMAP)}\
\
DEVICE_Pro2_Serial:shellypro2-DEVICE_Pro2_Serial/online:.* online
attr DEVICE_Pro2 room MQTT2_DEVICE
attr DEVICE_Pro2 setList toggle:noArg $DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Switch.Toggle","params": {"id":0}}\
off:noArg $DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Switch.Set","params": {"id":0,"on":false}}\
on:noArg $DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Switch.Set","params": {"id":0,"on":true}}\
on-for-timer $DEVICETOPIC/rpc {"id":0,"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}}\
status-request:noArg $DEVICETOPIC/rpc {"id":1,"src":"$DEVICETOPIC","method":"Switch.GetStatus","params": {"id":0}}
attr DEVICE_Pro2 webCmd :

define FileLog_DEVICE_Pro2 FileLog ./log/DEVICE_Pro2-%Y.log DEVICE_Pro2
attr FileLog_DEVICE_Pro2 logtype text
attr FileLog_DEVICE_Pro2 room MQTT2_DEVICE
# ------------------ Shelly Pro 2 - Kanal 1 - Ende ------------------
# ------------------ Shelly Pro 2 - Kanal 2 - Start ------------------
define DEVICE_Pro2_CH2 MQTT2_DEVICE
attr DEVICE_Pro2_CH2 comment Channel 2 for DEVICE_Pro2, see also DEVICE_Pro2, DEVICE_Pro2_CH3 and DEVICE_Pro2_CH4
attr DEVICE_Pro2_CH2 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') eq 'off'?'FS20.off':'FS20.on';; $light = FW_makeImage($light); 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>" }
attr DEVICE_Pro2_CH2 devicetopic shellypro2-DEVICE_Pro2_Serial
attr DEVICE_Pro2_CH2 event-on-change-reading state:on,state:off
attr DEVICE_Pro2_CH2 getList in_mode:noArg in_mode $DEVICETOPIC/rpc {"id": 1,"src":"$DEVICETOPIC", "method": "Switch.GetConfig", "params": {"id": 0}}
attr DEVICE_Pro2_CH2 group Versuchsschaltungen
attr DEVICE_Pro2_CH2 jsonMap params_switch_1_state:state params_switch_1_aenergy_total:aenergy_total params_switch_1_apower:apower params_switch_1_temperature_tC:temperature params_switch_1_temperature_tF:0
attr DEVICE_Pro2_CH2 model shellypro4pm
attr DEVICE_Pro2_CH2 readingList $DEVICETOPIC/events/rpc:.* { return if $EVENT !~ m{switch:1};; $EVENT =~ s/"output":true/"state":"on"/g;; $EVENT =~ s/"output":false/"state":"off"/g;; json2nameValue($EVENT,'',$JSONMAP) }\
  $DEVICETOPIC/status/switch.1:.* { json2nameValue($EVENT, '', $JSONMAP) }\
DEVICE_Pro2_Serial:shellypro2-DEVICE_Pro2_Serial/online:.* online
attr DEVICE_Pro2_CH2 room MQTT2_DEVICE
attr DEVICE_Pro2_CH2 setList toggle:noArg $DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Switch.Toggle","params": {"id":1}}\
  off:noArg $DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Switch.Set","params": {"id":1,"on":false}}\
  on:noArg $DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Switch.Set","params": {"id":1,"on":true}}\
  on-for-timer $DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Switch.Set","params": {"id":1,"on":true,"toggle_after":$EVTPART1}}\
  off-for-timer $DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Switch.Set","params": {"id":1,"on":false,"toggle_after":$EVTPART1}}
attr DEVICE_Pro2_CH2 setStateList on off toggle on-for-timer off-for-timer
attr DEVICE_Pro2_CH2 webCmd :
# ------------------ Shelly Pro 2 - Kanal 2 - Ende ------------------
# ****************** Shelly Pro 2 - Ende ******************

# ****************** Shelly Pro 3 - Start ******************
# ------------------ Shelly Pro 3 - Kanal 1 - Start ------------------
define DEVICE_Pro3 MQTT2_DEVICE shellypro3_DEVICE_Pro3_Serial
attr DEVICE_Pro3 IODev MQTT2
attr DEVICE_Pro3 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') eq 'off'?'FS20.off':'FS20.on';; $light = FW_makeImage($light); 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>" }
attr DEVICE_Pro3 devicetopic shellypro3-DEVICE_Pro3_Serial
attr DEVICE_Pro3 event-on-change-reading state:on,state:off
attr DEVICE_Pro3 group Versuchsschaltungen
attr DEVICE_Pro3 jsonMap\
switch_state:state\
switch_voltage:voltage\
switch_current:current\
switch_apower:power\
switch_temperature_tC:temperature\
switch_temperature_tF:0\
switch_source:source\
switch_id:0\
switch_dst:0\
switch_method:0\
switch_params_switch_0_id:0\
switch_params_switch_0_source:source\
switch_params_switch_0_state:state\
switch_params_switch_0_temperature_tC:temperature\
switch_params_switch_0_temperature_tFreq_dst:0\
req_dst:0\
req_id:0\
req_method:0\
req_params_id:0\
req_result_aenergy_by_minute_1:switch_aenergy_by_minute_1\
req_result_aenergy_by_minute_2:switch_aenergy_by_minute_2\
req_result_aenergy_by_minute_3:switch_aenergy_by_minute_3\
req_result_aenergy_minute_ts:switch_aenergy_minute_ts\
req_result_aenergy_total:switch_aenergy_total\
req_result_apower:power\
req_result_current:current\
req_result_id:0\
req_result_state:state\
req_result_pf:0\
req_result_source:source\
req_result_temperature_tC:temperature\
req_result_temperature_tF:0\
req_result_voltage:voltage\
req_src:0
attr DEVICE_Pro3 model shellyPro_3
attr DEVICE_Pro3 readingList $DEVICETOPIC/online:.* online\
$DEVICETOPIC/status/sys:.* { json2nameValue($EVENT) }\
$DEVICETOPIC/status/cloud:.* { json2nameValue($EVENT) }\
$DEVICETOPIC/status/mqtt:.* { json2nameValue($EVENT) }\
$DEVICETOPIC/events/rpc:.* { return if $EVENT !~ m{switch:0};; $EVENT =~ s/"output":true/"state":"on"/g;; $EVENT =~ s/"output":false/"state":"off"/g;; json2nameValue($EVENT,'switch_',$JSONMAP) }\
$DEVICETOPIC/status/switch.0:.* { $EVENT =~ s/"output":true/"state":"on"/g;; $EVENT =~ s/"output":false/"state":"off"/g;; json2nameValue($EVENT, 'switch_', $JSONMAP) }\
$DEVICETOPIC/rpc:.* { return if $EVENT !~ m{\"result\":\{\"id\":0};; $EVENT =~ s/"output":true/"state":"on"/g;; $EVENT =~ s/"output":false/"state":"off"/g;; json2nameValue($EVENT, 'req_', $JSONMAP)}\
\
shellypro3_DEVICE_Pro3_Serial:shellypro3-DEVICE_Pro3_Serial/online:.* online
attr DEVICE_Pro3 room MQTT2_DEVICE
attr DEVICE_Pro3 setList toggle:noArg $DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Switch.Toggle","params": {"id":0}}\
off:noArg $DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Switch.Set","params": {"id":0,"on":false}}\
on:noArg $DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Switch.Set","params": {"id":0,"on":true}}\
on-for-timer $DEVICETOPIC/rpc {"id":0,"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}}\
status-request:noArg $DEVICETOPIC/rpc {"id":1,"src":"$DEVICETOPIC","method":"Switch.GetStatus","params": {"id":0}}
attr DEVICE_Pro3 webCmd :

define FileLog_DEVICE_Pro3 FileLog ./log/DEVICE_Pro3-%Y.log DEVICE_Pro3
attr FileLog_DEVICE_Pro3 logtype text
attr FileLog_DEVICE_Pro3 room MQTT2_DEVICE
# ------------------ Shelly Pro 3 - Kanal 1 - Ende ------------------

# ------------------ Shelly Pro 3 - Kanal 2 - Start ------------------
define DEVICE_Pro3_CH2 MQTT2_DEVICE
attr DEVICE_Pro3_CH2 IODev MQTT2
attr DEVICE_Pro3_CH2 comment Channel 2 for DEVICE_Pro3, see also DEVICE_Pro3, DEVICE_Pro3_CH3 and DEVICE_Pro3_CH4
attr DEVICE_Pro3_CH2 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') eq 'off'?'FS20.off':'FS20.on';; $light = FW_makeImage($light); 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>" }
attr DEVICE_Pro3_CH2 devicetopic shellypro3-DEVICE_Pro3_Serial
attr DEVICE_Pro3_CH2 attr event-on-change-reading state:on,state:off
attr DEVICE_Pro3_CH2 group Versuchsschaltungen
attr DEVICE_Pro3_CH2 jsonMap\
params_switch_1_state:state\
params_switch_1_aenergy_total:aenergy_total\
params_switch_1_apower:apower\
params_switch_1_temperature_tC:temperature\
params_switch_1_temperature_tF:0
attr DEVICE_Pro3_CH2 model shellyPro_3
attr DEVICE_Pro3_CH2 readingList $DEVICETOPIC/events/rpc:.* { return if $EVENT !~ m{switch:1};; $EVENT =~ s/"output":true/"state":"on"/g;; $EVENT =~ s/"output":false/"state":"off"/g;; json2nameValue($EVENT,'',$JSONMAP) }\
  $DEVICETOPIC/status/switch.1:.* { json2nameValue($EVENT, '', $JSONMAP) }
attr DEVICE_Pro3_CH2 room MQTT2_DEVICE
attr DEVICE_Pro3_CH2 setList toggle:noArg $DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Switch.Toggle","params": {"id":1}}\
  off:noArg $DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Switch.Set","params": {"id":1,"on":false}}\
  on:noArg $DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Switch.Set","params": {"id":1,"on":true}}\
  on-for-timer $DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Switch.Set","params": {"id":1,"on":true,"toggle_after":$EVTPART1}}\
  off-for-timer $DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Switch.Set","params": {"id":1,"on":false,"toggle_after":$EVTPART1}}
attr DEVICE_Pro3_CH2 webCmd :
# ------------------ Shelly Pro 3 - Kanal 2 - Ende ------------------

# ------------------ Shelly Pro 3 - Kanal 3 - Start ------------------
define DEVICE_Pro3_CH3 MQTT2_DEVICE
attr DEVICE_Pro3_CH3 IODev MQTT2
attr DEVICE_Pro3_CH3 comment Channel 3 for DEVICE_Pro3, see also DEVICE_Pro3, DEVICE_Pro3_CH2 and DEVICE_Pro3_CH4
attr DEVICE_Pro3_CH3 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') eq 'off'?'FS20.off':'FS20.on';; $light = FW_makeImage($light); 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>" }
attr DEVICE_Pro3_CH3 devicetopic shellypro3-DEVICE_Pro3_Serial
attr DEVICE_Pro3_CH3 attr event-on-change-reading state:on,state:off
attr DEVICE_Pro3_CH3 group Versuchsschaltungen
attr DEVICE_Pro3_CH3 jsonMap\
params_switch_2_state:state\
params_switch_2_aenergy_total:aenergy_total\
params_switch_2_apower:apower\
params_switch_2_temperature_tC:temperature\
params_switch_2_temperature_tF:0
attr DEVICE_Pro3_CH3 model shellyPro_3
attr DEVICE_Pro3_CH3 readingList $DEVICETOPIC/events/rpc:.* { return if $EVENT !~ m{switch:2};; $EVENT =~ s/"output":true/"state":"on"/g;; $EVENT =~ s/"output":false/"state":"off"/g;; json2nameValue($EVENT,'',$JSONMAP) }\
  $DEVICETOPIC/status/switch.2:.* { json2nameValue($EVENT, '', $JSONMAP) }
attr DEVICE_Pro3_CH3 room MQTT2_DEVICE
attr DEVICE_Pro3_CH3 setList toggle:noArg $DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Switch.Toggle","params": {"id":2}}\
  off:noArg $DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Switch.Set","params": {"id":2,"on":false}}\
  on:noArg $DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Switch.Set","params": {"id":2,"on":true}}\
  on-for-timer $DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Switch.Set","params": {"id":2,"on":true,"toggle_after":$EVTPART1}}\
  off-for-timer $DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Switch.Set","params": {"id":2,"on":false,"toggle_after":$EVTPART1}}
attr DEVICE_Pro3_CH3 webCmd :
# ------------------ Shelly Pro 3 - Kanal 3 - Ende ------------------
# ****************** Shelly Pro 3 - Ende ******************

Was natürlich toll wäre ist ein entsprechendes Template welches die Grundbedürfnisse abdeckt. Ich habe ein paar Versuche gewagt, scheitere jedoch an meinen Fähigkeiten.

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

Beta-User

@vic: Tut mir leid, aber ich finde diese "funktionierende Konfiguration" sehr irritierend.

V.a. stellt sich die Frage, warum man manches doppelt braucht. Beispiel:
attr DEVICE_Pro1 readingList $DEVICETOPIC/online:.* online\
shellypro1_DEVICE_Pro1_Serial:shellypro1-DEVICE_Pro1_Serial/online:.* online\

Warum einmal mit $DEVICETOPIC und dann nochmal? Noch komischer wird das, wenn einem json2nameValue() mit weiteren Argumenten aufgerufen wird und einmal ohne.
Warum werden die 2. Zeilen überhaupt angelegt? Hast du das manuell gemacht? Warum?!?

Von daher sehe ich mich grade nicht in der Lage, daraus was allgemeingültiges zu basteln.
Server: HP-elitedesk@Debian 12, aktuelles FHEM@ConfigDB | CUL_HM (VCCU) | MQTT2: MiLight@ESP-GW, BT@OpenMQTTGw | MySensors: seriell, v.a. 2.3.1@RS485 | ZWave | ZigBee@deCONZ | SIGNALduino | MapleCUN | RHASSPY
svn: u.a MySensors, Weekday-&RandomTimer, Twilight,  div. attrTemplate-files

vic

Vielen Dank für deine Antwort Beta-User

Bitte entschuldigt alle, dass ich jeweils so spät antworte. Ich bin nebst Arbeit mit Betreuung und Spitalaufenthalten komplett zugemüllt und kann daher nicht sofort reagieren.

@Beta-User: Zu deiner Frage woher... Ich habe ausgehende von Vorschlägen in Kombination mit dem ShellyPro4pm-Template so weit gebastelt bis es funktionierte. Ich bin keine Programmier-Hero und jeweils sehr froh gewesen wenn ein funktionierendes Template zur Verfügung stand. Die aufgelistete Funktion funktioniert so wie ich es gerne hätte. Mein Bedürfnis ist lediglich Ein, Aus, Toggle und entsprechende Rückmeldungen. Also nichts komplexes. Mir ist bewusst, dass meine Vorgehensweise absolut dilettantisch ist. Mit den vielen Möglichkeiten und Funktionen bin ich schlichtweg überfordert. Darum bin ich auf eure Hilfe angewiesen und ausserordentlich dankbar.

Im Moment sieht der Code folgendermassen aus:

# ****************** Shelly Pro 1 - Start ******************
define DEVICE_Pro1 MQTT2_DEVICE shellypro1_DEVICE_Pro1_Serial
setuuid DEVICE_Pro1 641c1699-f33f-0f0b-0e50-afcd1c263ddbc307
attr DEVICE_Pro1 alias SH_AKT_253_Test
attr DEVICE_Pro1 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') eq 'off'?'FS20.off':'FS20.on';;;; $light = FW_makeImage($light);; 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>" }
attr DEVICE_Pro1 devicetopic shellypro1-DEVICE_Pro1_Serial
attr DEVICE_Pro1 event-on-change-reading state:on state:off
attr DEVICE_Pro1 getList in_mode:noArg in_mode $DEVICETOPIC/rpc {"id": 1,"src":"$DEVICETOPIC", "method": "Switch.GetConfig", "params": {"id": 0}}
attr DEVICE_Pro1 group Versuchsschaltungen
attr DEVICE_Pro1 icon message_socket
attr DEVICE_Pro1 jsonMap switch_state:state\
switch_source:source\
switch_id:0\
switch_dst:0\
switch_method:0\
switch_params_switch_0_id:0\
switch_params_switch_0_source:source\
switch_params_switch_0_state:state\
req_dst:0\
req_id:0\
req_method:0\
req_params_id:0\
req_result_id:0\
req_result_state:state\
req_result_pf:0\
req_result_source:source\
req_src:0
attr DEVICE_Pro1 model shellyPro_1
attr DEVICE_Pro1 readingList $DEVICETOPIC/online:.* online\
$DEVICETOPIC/status/sys:.* { json2nameValue($EVENT) }\
$DEVICETOPIC/status/cloud:.* { json2nameValue($EVENT) }\
$DEVICETOPIC/status/mqtt:.* { json2nameValue($EVENT) }\
$DEVICETOPIC/events/rpc:.* { return if $EVENT !~ m{switch:0};; $EVENT =~ s/"output":true/"state":"on"/g;; $EVENT =~ s/"output":false/"state":"off"/g;; json2nameValue($EVENT,'switch_',$JSONMAP) }\
$DEVICETOPIC/status/switch.0:.* { $EVENT =~ s/"output":true/"state":"on"/g;; $EVENT =~ s/"output":false/"state":"off"/g;; json2nameValue($EVENT, 'switch_', $JSONMAP) }\
$DEVICETOPIC/rpc:.* { return if $EVENT !~ m{\"result\":\{\"id\":0};; $EVENT =~ s/"output":true/"state":"on"/g;; $EVENT =~ s/"output":false/"state":"off"/g;; json2nameValue($EVENT, 'req_', $JSONMAP)}
attr DEVICE_Pro1 room MQTT2_DEVICE
attr DEVICE_Pro1 setList toggle:noArg $DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Switch.Toggle","params": {"id":0}}\
  off:noArg $DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Switch.Set","params": {"id":0,"on":false}}\
  on:noArg $DEVICETOPIC/rpc {"id":0,"src":"fhem2shelly","method":"Switch.Set","params": {"id":0,"on":true}}\
  on-for-timer $DEVICETOPIC/rpc {"id":0,"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}}\
  in_mode:toggle,flip,detached {fhem("sleep 0.2;; get $NAME in_mode");; my $val = $EVTPART1 ne 'toggle' ? $EVTPART1 : ReadingsVal($NAME,'in_mode','flip') eq 'flip' ? 'detached':'flip';; qq($DEVICETOPIC/rpc {"id":1,"src":"fhem2shelly","method":"Switch.SetConfig","params": {"id":0, "config": {"in_mode": "$val"}}})}\
  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"}
attr DEVICE_Pro1 setStateList on off toggle on-for-timer off-for-timer
attr DEVICE_Pro1 webCmd :




define FileLog_DEVICE_Pro1 FileLog ./log/DEVICE_Pro1-%Y.log DEVICE_Pro1
setuuid FileLog_DEVICE_Pro1 641c1699-f33f-0f0b-ecf0-1c19c355e21c2ad6
attr FileLog_DEVICE_Pro1 logtype text
attr FileLog_DEVICE_Pro1 room MQTT2_DEVICE
# ****************** Shelly Pro 1 - Ende ******************

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

vic

Guten Tag liebe Gemeinde

Die ShellyPro-Serie scheint gut zu funktionieren.
Leider habe ich ein Symptom festgestellt welches störend ist.
Wenn bei einem beliebigen Shelly mit on einschaltet wird und anschliessend nochmals der Befehl on ausgelöst wird bleibt der state auf set_on hängen.

Als Zwischenlösung habe ich folgendes devStateIcon eingetragen:
{my $onl = ReadingsVal($name,'online','false') eq 'false'?'10px-kreis-rot':'10px-kreis-gruen'; $onl = FW_makeImage($onl); my $light = ReadingsVal($name,'state','off') eq 'off'?'FS20.off':ReadingsVal($name,'state','off') eq 'set_off' ? 'FS20.off':ReadingsVal($name,'state','off') eq 'on' ? 'FS20.on':ReadingsVal($name,'state','off') eq 'set_on' ? 'FS20.on':'FS20.on';; $light = FW_makeImage($light); my $temp = ReadingsVal($name,'temperature','-100'); my $ip = ReadingsVal($name,'ip','none'); my $reb = ReadingsVal($name,'sys_restart_required','false') eq 'true'?'<a href="/fhem?cmd.dummy=set '.$name.' x_reboot&XHR=1"> ... Notwendigen Reboot durchführen</a>':''; qq(<a href="http://$ip" target="_blank">${onl}</a><a href="/fhem?cmd.dummy=set $name toggle&XHR=1">${light}</a>$reb<div>Temp: $temp °C</div>)}

Wobei vom Original der Teil
my $light = FW_makeImage(ReadingsVal($name,'state','off'));

mit dem folgenden
my $light = ReadingsVal($name,'state','off') eq 'off'?'FS20.off':ReadingsVal($name,'state','off') eq 'set_off' ? 'FS20.off':ReadingsVal($name,'state','off') eq 'on' ? 'FS20.on':ReadingsVal($name,'state','off') eq 'set_on' ? 'FS20.on':'FS20.on';; $light = FW_makeImage($light);

ausgetauscht wurde.

Kennt ihr eine elegantere Lösung?

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

Beta-User

Zitat von: vic am 09 Oktober 2023, 10:01:32Kennt ihr eine elegantere Lösung?
Weiß nicht recht...

Dein workaround "berichtigt" (?) die Anzeige auf den Soll-Wert.

Eigentlich sollte der Shelly zurückmelden, wohin er geschaltet hat. Tut er das nicht (bzw. bei zu schneller Wiederholung nicht mehr), ist was anderes faul, entweder die  firmware auf dem Shelly oder die WLAN- oder MQTT-Verbindung.

Vielleicht ist es auch nicht optimal, den internen toggle-Befehl des Shelly zu nutzen beim Klick auf das Symbol?

Würde das gerne klären, bevor wir am attrTemplate was ändern.
Server: HP-elitedesk@Debian 12, aktuelles FHEM@ConfigDB | CUL_HM (VCCU) | MQTT2: MiLight@ESP-GW, BT@OpenMQTTGw | MySensors: seriell, v.a. 2.3.1@RS485 | ZWave | ZigBee@deCONZ | SIGNALduino | MapleCUN | RHASSPY
svn: u.a MySensors, Weekday-&RandomTimer, Twilight,  div. attrTemplate-files