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-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

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!

amehl

Hallo,
ich hole das Thema noch mal hoch, da ich das gleich Problem habe. Der Shelly Plus Plug S läuft und läst sich auch schalten. Es wird aber kein Zustand on/off (Lampe) und kein Verbrauch angezeigt.
Ich komme einfach nicht weiter.
Hier ein List:
Internals:
  CID        shellyplusplugs_c82e180774e0
  DEF        shellyplusplugs_c82e180774e0
  FUUID      6595bcd9-f33f-9aee-e4fa-33196b2cfcf66594
  IODev      MQTT
  LASTInputDev MQTT
  MQTT_CONN  MQTT_192.168.178.139_51014
  MQTT_MSGCNT 66
  MQTT_TIME  2024-01-04 11:22:27
  MSGCNT    66
  NAME      Test11
  NR        430
  STATE      set_toggle
  TYPE      MQTT2_DEVICE
  eventCount 5
  JSONMAP:
    params_switch_0_temperature_tC temperature
    params_switch_0_temperature_tF 0
    params_wifi_sta_ip ip
    result_in_mode in_mode
    switch_aenergy_total aenergy_total
    switch_apower apower
    switch_state state
    switch_temperature_tC temperature
    switch_temperature_tF 0
  READINGS:
    2024-01-04 10:56:27  IODev          MQTT
    2024-01-03 21:25:02  attrTemplateVersion 20220304
    2024-01-04 11:22:27  dst            shellyplusplugs-c82e180774e0/events
    2024-01-04 11:19:02  ip              192.168.178.139
    2024-01-04 11:22:27  method          NotifyStatus
    2024-01-04 11:19:02  online          true
    2024-01-04 11:19:02  params_cloud_connected false
    2024-01-04 11:19:02  params_mqtt_connected true
    2024-01-04 11:21:00  params_switch_0_aenergy_by_minute_1 840.423
    2024-01-04 11:21:00  params_switch_0_aenergy_by_minute_2 536.377
    2024-01-04 11:21:00  params_switch_0_aenergy_by_minute_3 0.000
    2024-01-04 11:21:00  params_switch_0_aenergy_minute_ts 1704363659
    2024-01-04 11:21:00  params_switch_0_aenergy_total 1.377
    2024-01-04 11:22:27  params_switch_0_apower 49.5
    2024-01-04 11:19:23  params_switch_0_current 0.382
    2024-01-04 11:22:27  params_switch_0_id 0
    2024-01-04 11:19:19  params_switch_0_output true
    2024-01-04 11:19:19  params_switch_0_source button
    2024-01-04 11:19:02  params_switch_0_temperature_tC 33.8
    2024-01-04 11:19:02  params_switch_0_temperature_tF 92.9
    2024-01-04 11:19:20  params_switch_0_voltage 216.6
    2024-01-04 11:19:09  params_sys_available_updates_stable_version 1.1.0
    2024-01-04 11:19:02  params_sys_cfg_rev 4
    2024-01-04 11:19:02  params_sys_fs_free 143360
    2024-01-04 11:19:02  params_sys_fs_size 458752
    2024-01-04 11:19:02  params_sys_kvs_rev 0
    2024-01-04 11:19:02  params_sys_mac  C82E180774E0
    2024-01-04 11:19:02  params_sys_ram_free 130168
    2024-01-04 11:19:02  params_sys_ram_size 261224
    2024-01-04 11:19:02  params_sys_restart_required false
    2024-01-04 11:19:02  params_sys_schedule_rev 0
    2024-01-04 10:56:48  params_sys_time 10:56
    2024-01-04 10:56:48  params_sys_unixtime 1704362208
    2024-01-04 11:19:02  params_sys_uptime 1
    2024-01-04 11:19:02  params_sys_webhook_rev 0
    2024-01-04 11:22:27  params_ts      1704363687.12
    2024-01-04 11:19:02  params_wifi_rssi -77
    2024-01-04 11:19:02  params_wifi_ssid LIMA
    2024-01-04 11:19:02  params_wifi_sta_ip 192.168.178.139
    2024-01-04 11:19:02  params_wifi_status got ip
    2024-01-04 11:19:02  params_ws_connected false
    2024-01-04 11:22:27  src            shellyplusplugs-c82e180774e0
    2024-01-04 10:56:48  statStateDay    set_toggle: 00:05:07 set_toggle_Count: 1 (since: 2024-01-04_10:51:41)
    2024-01-04 10:56:48  statStateMonth  set_toggle: 00:05:07 set_toggle_Count: 1 (since: 2024-01-04_10:51:41)
    2024-01-04 10:56:48  statStateYear  set_toggle: 00:05:07 set_toggle_Count: 1 (since: 2024-01-04_10:51:41)
    2024-01-04 11:19:02  statTemperatureDay Min: 37.8 Avg: 37.8 Max: 39.9 (since: 2024-01-04_10:56:48 )
    2024-01-04 11:19:02  statTemperatureMonth Min: 37.8 Avg: 37.8 Max: 39.9 (since: 2024-01-04_10:56:48 )
    2024-01-04 11:19:02  statTemperatureYear Min: 37.8 Avg: 37.8 Max: 39.9 (since: 2024-01-04_10:56:48 )
    2024-01-04 11:07:47  state          set_toggle
    2024-01-04 11:19:02  temperature    33.8
    2024-01-03 21:25:02  x_reboot        set
  helper:
    _98_statistics Datensammler
Attributes:
  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>)}
  devicetopic shellyplusplugs-c82e180774e0
  event-on-change-reading apower:50,aenergy_total:100,temperature:5,state,status,switch_current:1,sys_restart_required,online
  getList    in_mode:noArg in_mode $DEVICETOPIC/rpc {"id": 1,"src":"$DEVICETOPIC", "method": "Switch.GetConfig", "params": {"id": 0}}
  icon      message_socket
  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
  model      shellyPlus_1pm
  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:.* {}
shellyplusplugs_c82e180774e0:shellyplusplugs-c82e180774e0/events/rpc:.* { json2nameValue($EVENT) }
shellyplusplugs_c82e180774e0:shellyplusplugs-c82e180774e0/online:.* online
  room      MQTT2_DEVICE,Shelly
  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