Template für "Shelly Plus Plug S"

Begonnen von octek0815, 05 Juni 2023, 08:33:13

Vorheriges Thema - Nächstes Thema

octek0815

Hallo,

hat jemand ein "Shelly Plus Plug S" schon am laufen.
Habe es mit dem Template "shellyPlus_1pm" probiert, es funktioniert jedoch nicht.

LG
Olli

viegener

Ja ich habe mehrere Shelly Plus Plug S am Laufen. Ich habe als Grundlage auch das "shellyPlus_1pm" template verwendet, allerdings muss dann wohl noch das devicetopic Attribut angepasst werden. Wenn es damit nicht funktioniert wäre ein list des devices hilfreich.

Ich habe noch einige Anpassungen bei mir an den devices von Hand gemacht, aber noch nichts ins template einfliessen lassen. Mein Ziel wäre eine einigermassen einheitliche Readingstruktur für die verschiedenen Shelly-plugs zu haben.

Kein Support über PM - Anfragen gerne im Forum - Damit auch andere profitieren und helfen können

octek0815

Hallo und vielen Dank für deine Antwort!

Leider fehlt mir aber das nötige Wissen was ich da genau anpassen (devicetopic Attribut) muss.

Hier ein List vom Device...

Internals:
   CFGFN     
   CID        shellyplusplugs_d4d4da7c00fc
   DEF        shellyplusplugs_d4d4da7c00fc
   FUUID      647da38e-f33f-445e-0da7-87316ca215a0f3b4
   IODev      System_MQTT_Broker
   LASTInputDev System_MQTT_Broker
   MSGCNT     8
   NAME       MQTT2_shellyplusplugs_d4d4da7c00fc
   NR         46010
   STATE      ???
   System_MQTT_Broker_CONN System_MQTT_Broker_10.208.3.107_57111
   System_MQTT_Broker_MSGCNT 8
   System_MQTT_Broker_TIME 2023-06-05 10:58:05
   TYPE       MQTT2_DEVICE
   eventCount 13
   READINGS:
     2023-06-05 10:57:50   IODev           System_MQTT_Broker
     2023-06-05 10:58:05   aenergy_by_minute_1 0.000
     2023-06-05 10:58:05   aenergy_by_minute_2 0.000
     2023-06-05 10:58:05   aenergy_by_minute_3 0.000
     2023-06-05 10:58:05   aenergy_minute_ts 1685955484
     2023-06-05 10:58:05   aenergy_total   0.000
     2023-06-05 10:58:05   apower          0.0
     2023-06-05 10:57:57   available_updates_beta_version 1.0.0-beta2
     2023-06-05 10:57:57   cfg_rev         30
     2023-06-05 10:57:50   connected       true
     2023-06-05 10:58:05   current         0.000
     2023-06-05 10:58:05   dst             shellyplusplugs-d4d4da7c00fc/events
     2023-06-05 10:57:57   fs_free         94208
     2023-06-05 10:57:57   fs_size         458752
     2023-06-05 10:58:05   id              0
     2023-06-05 10:57:57   kvs_rev         3
     2023-06-05 10:57:57   mac             D4D4DA7C00FC
     2023-06-05 10:58:05   method          NotifyStatus
     2023-06-05 10:57:50   online          true
     2023-06-05 10:58:05   output          false
     2023-06-05 10:57:50   params_mqtt_connected true
     2023-06-05 10:58:00   params_switch_0_aenergy_by_minute_1 0.000
     2023-06-05 10:58:00   params_switch_0_aenergy_by_minute_2 0.000
     2023-06-05 10:58:00   params_switch_0_aenergy_by_minute_3 0.000
     2023-06-05 10:58:00   params_switch_0_aenergy_minute_ts 1685955479
     2023-06-05 10:58:00   params_switch_0_aenergy_total 0.000
     2023-06-05 10:58:05   params_switch_0_apower 0
     2023-06-05 10:58:05   params_switch_0_current 0
     2023-06-05 10:58:05   params_switch_0_id 0
     2023-06-05 10:58:05   params_switch_0_output false
     2023-06-05 10:58:05   params_switch_0_source button
     2023-06-05 10:58:05   params_switch_0_voltage 0
     2023-06-05 10:57:57   params_sys_available_updates_beta_version 1.0.0-beta2
     2023-06-05 10:58:05   params_ts       1685955486.33
     2023-06-05 10:57:57   ram_free        160412
     2023-06-05 10:57:57   ram_size        234712
     2023-06-05 10:57:57   restart_required false
     2023-06-05 10:57:57   schedule_rev    4
     2023-06-05 10:58:05   source          button
     2023-06-05 10:58:05   src             shellyplusplugs-d4d4da7c00fc
     2023-06-05 10:58:05   temperature_tC  40.9
     2023-06-05 10:58:05   temperature_tF  105.7
     2023-06-05 10:57:57   time            10:57
     2023-06-05 10:57:57   unixtime        1685955477
     2023-06-05 10:57:57   uptime          8
     2023-06-05 10:58:05   voltage         0.0
     2023-06-05 10:57:57   webhook_rev     0
Attributes:
   readingList shellyplusplugs_d4d4da7c00fc:shellyplusplugs-d4d4da7c00fc/online:.* online
shellyplusplugs_d4d4da7c00fc:shellyplusplugs-d4d4da7c00fc/status/mqtt:.* { json2nameValue($EVENT) }
shellyplusplugs_d4d4da7c00fc:shellyplusplugs-d4d4da7c00fc/events/rpc:.* { json2nameValue($EVENT) }
shellyplusplugs_d4d4da7c00fc:shellyplusplugs-d4d4da7c00fc/status/sys:.* { json2nameValue($EVENT) }
shellyplusplugs_d4d4da7c00fc:shellyplusplugs-d4d4da7c00fc/status/switch_0:.* { json2nameValue($EVENT) }
   room       MQTT2_DEVICE

viegener

Du kannst mal folgende Einstellungen verwenden - Ansonsten sollten wir die MQTT/API-Einstellungen im Device vielleicht vergleichen

Ich habe es bereits schonmal auf Deinen Devicenamen angepasst

attr MQTT2_shellyplusplugs_d4d4da7c00fc 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 $cons = ReadingsNum($name,'apower',0);; my $total = round(ReadingsNum($name,'aenergy_total',0)/1000,3);; 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>Verbrauch: $cons W / Total: $total kwh / Temp: $temp °C</div>)}
attr MQTT2_shellyplusplugs_d4d4da7c00fc devicetopic shellyplusplugs_d4d4da7c00fc
attr MQTT2_shellyplusplugs_d4d4da7c00fc event-on-change-reading apower:50,aenergy_total:100,temperature:5,state,status,switch_current:1,sys_restart_required,online
attr MQTT2_shellyplusplugs_d4d4da7c00fc genericDeviceType switch
attr MQTT2_shellyplusplugs_d4d4da7c00fc getList in_mode:noArg in_mode $DEVICETOPIC/rpc {"id": 1,"src":"$DEVICETOPIC", "method": "Switch.GetConfig", "params": {"id": 0}}
attr MQTT2_shellyplusplugs_d4d4da7c00fc group fixed,shelly
attr MQTT2_shellyplusplugs_d4d4da7c00fc icon remotecontrol/black_btn_PS3Circle
attr MQTT2_shellyplusplugs_d4d4da7c00fc jsonMap switch_state:state switch_aenergy_total:aenergy_total switch_apower:apower 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 result_in_mode:in_mode
attr MQTT2_shellyplusplugs_d4d4da7c00fc model shellyPlus_1pm_plustest
attr MQTT2_shellyplusplugs_d4d4da7c00fc 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/announce:.* { json2nameValue($EVENT,'ann_', $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:.* {}\
shellyplusplugs_d4d4da7c00fc:shellyplusplugs_d4d4da7c00fc/status/wifi:.* { json2nameValue($EVENT) }\

attr MQTT2_shellyplusplugs_d4d4da7c00fc room MQTT2_DEVICE,Actor,Sensor
attr MQTT2_shellyplusplugs_d4d4da7c00fc 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 MQTT2_shellyplusplugs_d4d4da7c00fc setStateList on off toggle on-for-timer off-for-timer
attr MQTT2_shellyplusplugs_d4d4da7c00fc webCmd :
Kein Support über PM - Anfragen gerne im Forum - Damit auch andere profitieren und helfen können

octek0815

Funktioniert leider nicht...

Was ist "fhem2shelly" bei den setList´s?

Beta-User

Versuch's mal mit - statt Unterstrich im devicetopic.
Server: HP-T620@Debian 11, 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

octek0815

Damit klappt es.

Vielen Dank für Deine Hilfe!


viegener

Zitat von: octek0815 am 05 Juni 2023, 14:31:26Damit klappt es.

Vielen Dank für Deine Hilfe!



Ja - Sorry - der Default ist mit Bindestrich
Kein Support über PM - Anfragen gerne im Forum - Damit auch andere profitieren und helfen können

octek0815

Kein Problem, und danke für deine Hilfe!