Shelly Plus1PM: Reading IP-Adresse fehlt

Begonnen von oelidoc, 18 März 2023, 17:39:41

Vorheriges Thema - Nächstes Thema

oelidoc

Hallo,
ich habe per autocreate einen neuen Shelly Plus1PM angelegt und ihm das gleichnamige Template zugewiesen. Schalten geht.
Der Shelly hat die FW 0.14.1. Leider funktioniert das Anklicken des grünen Punktes nicht, um auf die Gerätewebsite zu kommen. Die Anzeige einer neuen FW dürfte dementsprechend auch nicht funktionieren. Ist zwar nur ein kosmetischer Fehler, ich nutze das Feature jedoch relativ oft. Irgendwie fehlen bei meinem device die notwendigen WLAN-Readings...

define MQTT2_shellyplus1pm MQTT2_DEVICE shellyplus1pm
attr MQTT2_shellyplus1pm 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>)}
attr MQTT2_shellyplus1pm devicetopic shellyplus1pm
attr MQTT2_shellyplus1pm event-on-change-reading .*
attr MQTT2_shellyplus1pm genericDeviceType switch
attr MQTT2_shellyplus1pm getList in_mode:noArg in_mode $DEVICETOPIC/rpc {"id": 1,"src":"$DEVICETOPIC", "method": "Switch.GetConfig", "params": {"id": 0}}
attr MQTT2_shellyplus1pm icon message_socket
attr MQTT2_shellyplus1pm 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 MQTT2_shellyplus1pm model shellyPlus_1
attr MQTT2_shellyplus1pm 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:.* {}
attr MQTT2_shellyplus1pm room MQTT2_DEVICE
attr MQTT2_shellyplus1pm 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_shellyplus1pm setStateList on off toggle on-for-timer off-for-timer
attr MQTT2_shellyplus1pm webCmd :
#   CFGFN     
#   CID        shellyplus1pm
#   DEF        shellyplus1pm
#   FUUID      6415acab-f33f-74ea-9efc-4027b02d3a772a61
#   IODev      myBroker
#   LASTInputDev myBroker
#   MSGCNT     583
#   NAME       MQTT2_shellyplus1pm
#   NR         791
#   STATE      off
#   TYPE       MQTT2_DEVICE
#   eventCount 584
#   myBroker_CONN myBroker_192.168.178.75_56545
#   myBroker_MSGCNT 583
#   myBroker_TIME 2023-03-18 17:16:59
#   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
#   OLDREADINGS:
#   READINGS:
#     2023-03-18 13:20:59   IODev           myBroker
#     2023-03-18 13:22:30   attrTemplateVersion 20220304
#     2023-03-18 17:16:58   dst             shellyplus1pm/events
#     2023-03-18 17:16:58   method          NotifyStatus
#     2023-03-18 14:08:01   mqtt_connected  true
#     2023-03-18 14:08:01   online          true
#     2023-03-18 14:07:53   params_events_1_cfg_rev 28
#     2023-03-18 14:07:57   params_events_1_component sys
#     2023-03-18 14:07:57   params_events_1_event scheduled_restart
#     2023-03-18 14:07:53   params_events_1_restart_required true
#     2023-03-18 14:07:57   params_events_1_time_ms 997
#     2023-03-18 14:07:57   params_events_1_ts 1679144877.42
#     2023-03-18 14:08:01   params_mqtt_connected true
#     2023-03-18 17:16:58   params_switch_0_aenergy_by_minute_1 0.000
#     2023-03-18 17:16:58   params_switch_0_aenergy_by_minute_2 0.000
#     2023-03-18 17:16:58   params_switch_0_aenergy_by_minute_3 0.000
#     2023-03-18 17:16:58   params_switch_0_aenergy_minute_ts 1679156219
#     2023-03-18 17:16:58   params_switch_0_aenergy_total 25.161
#     2023-03-18 14:10:51   params_switch_0_apower 0
#     2023-03-18 14:10:51   params_switch_0_current 0
#     2023-03-18 17:16:58   params_switch_0_id 0
#     2023-03-18 14:10:51   params_switch_0_output false
#     2023-03-18 14:10:51   params_switch_0_source MQTT
#     2023-03-18 14:07:53   params_sys_cfg_rev 28
#     2023-03-18 14:07:53   params_sys_restart_required true
#     2023-03-18 17:16:58   params_ts       1679156220.60
#     2023-03-18 17:16:58   src             shellyplus1pm-4855199cb07c
#     2023-03-18 17:16:59   state           off
#     2023-03-18 13:44:29   subscriptions   shellies/command shellyplus1pm/command shellyplus1pm/command/switch:0 shellyplus1pm/command/sys shellyplus1pm/rpc
#     2023-03-18 17:16:59   switch_aenergy_by_minute_1 0.000
#     2023-03-18 17:16:59   switch_aenergy_by_minute_2 0.000
#     2023-03-18 17:16:59   switch_aenergy_by_minute_3 0.000
#     2023-03-18 17:16:59   switch_aenergy_minute_ts 1679156219
#     2023-03-18 17:16:59   switch_aenergy_total 25.161
#     2023-03-18 17:16:59   switch_apower   0.0
#     2023-03-18 17:16:59   switch_current  0.000
#     2023-03-18 17:16:59   switch_id       0
#     2023-03-18 17:16:59   switch_source   MQTT
#     2023-03-18 17:16:59   switch_voltage  226.8
#     2023-03-18 14:08:13   sys_cfg_rev     28
#     2023-03-18 14:08:13   sys_fs_free     98304
#     2023-03-18 14:08:13   sys_fs_size     458752
#     2023-03-18 14:08:13   sys_kvs_rev     2
#     2023-03-18 14:08:13   sys_mac         4855199CB07C
#     2023-03-18 14:08:13   sys_ram_free    159840
#     2023-03-18 14:08:13   sys_ram_size    234620
#     2023-03-18 14:08:13   sys_restart_required false
#     2023-03-18 14:08:13   sys_schedule_rev 0
#     2023-03-18 14:08:13   sys_time        14:08
#     2023-03-18 14:08:13   sys_unixtime    1679144894
#     2023-03-18 14:08:13   sys_uptime      14
#     2023-03-18 14:08:13   sys_webhook_rev 0
#     2023-03-18 17:16:59   temperature     27.8
#     2023-03-18 13:22:31   x_reboot        set
#   hmccu:
#
setstate MQTT2_shellyplus1pm off
setstate MQTT2_shellyplus1pm 2023-03-18 13:20:59 IODev myBroker
setstate MQTT2_shellyplus1pm 2023-03-18 13:22:30 attrTemplateVersion 20220304
setstate MQTT2_shellyplus1pm 2023-03-18 17:16:58 dst shellyplus1pm/events
setstate MQTT2_shellyplus1pm 2023-03-18 17:16:58 method NotifyStatus
setstate MQTT2_shellyplus1pm 2023-03-18 14:08:01 mqtt_connected true
setstate MQTT2_shellyplus1pm 2023-03-18 14:08:01 online true
setstate MQTT2_shellyplus1pm 2023-03-18 14:07:53 params_events_1_cfg_rev 28
setstate MQTT2_shellyplus1pm 2023-03-18 14:07:57 params_events_1_component sys
setstate MQTT2_shellyplus1pm 2023-03-18 14:07:57 params_events_1_event scheduled_restart
setstate MQTT2_shellyplus1pm 2023-03-18 14:07:53 params_events_1_restart_required true
setstate MQTT2_shellyplus1pm 2023-03-18 14:07:57 params_events_1_time_ms 997
setstate MQTT2_shellyplus1pm 2023-03-18 14:07:57 params_events_1_ts 1679144877.42
setstate MQTT2_shellyplus1pm 2023-03-18 14:08:01 params_mqtt_connected true
setstate MQTT2_shellyplus1pm 2023-03-18 17:16:58 params_switch_0_aenergy_by_minute_1 0.000
setstate MQTT2_shellyplus1pm 2023-03-18 17:16:58 params_switch_0_aenergy_by_minute_2 0.000
setstate MQTT2_shellyplus1pm 2023-03-18 17:16:58 params_switch_0_aenergy_by_minute_3 0.000
setstate MQTT2_shellyplus1pm 2023-03-18 17:16:58 params_switch_0_aenergy_minute_ts 1679156219
setstate MQTT2_shellyplus1pm 2023-03-18 17:16:58 params_switch_0_aenergy_total 25.161
setstate MQTT2_shellyplus1pm 2023-03-18 14:10:51 params_switch_0_apower 0
setstate MQTT2_shellyplus1pm 2023-03-18 14:10:51 params_switch_0_current 0
setstate MQTT2_shellyplus1pm 2023-03-18 17:16:58 params_switch_0_id 0
setstate MQTT2_shellyplus1pm 2023-03-18 14:10:51 params_switch_0_output false
setstate MQTT2_shellyplus1pm 2023-03-18 14:10:51 params_switch_0_source MQTT
setstate MQTT2_shellyplus1pm 2023-03-18 14:07:53 params_sys_cfg_rev 28
setstate MQTT2_shellyplus1pm 2023-03-18 14:07:53 params_sys_restart_required true
setstate MQTT2_shellyplus1pm 2023-03-18 17:16:58 params_ts 1679156220.60
setstate MQTT2_shellyplus1pm 2023-03-18 17:16:58 src shellyplus1pm-4855199cb07c
setstate MQTT2_shellyplus1pm 2023-03-18 17:16:59 state off
setstate MQTT2_shellyplus1pm 2023-03-18 13:44:29 subscriptions shellies/command shellyplus1pm/command shellyplus1pm/command/switch:0 shellyplus1pm/command/sys shellyplus1pm/rpc
setstate MQTT2_shellyplus1pm 2023-03-18 17:16:59 switch_aenergy_by_minute_1 0.000
setstate MQTT2_shellyplus1pm 2023-03-18 17:16:59 switch_aenergy_by_minute_2 0.000
setstate MQTT2_shellyplus1pm 2023-03-18 17:16:59 switch_aenergy_by_minute_3 0.000
setstate MQTT2_shellyplus1pm 2023-03-18 17:16:59 switch_aenergy_minute_ts 1679156219
setstate MQTT2_shellyplus1pm 2023-03-18 17:16:59 switch_aenergy_total 25.161
setstate MQTT2_shellyplus1pm 2023-03-18 17:16:59 switch_apower 0.0
setstate MQTT2_shellyplus1pm 2023-03-18 17:16:59 switch_current 0.000
setstate MQTT2_shellyplus1pm 2023-03-18 17:16:59 switch_id 0
setstate MQTT2_shellyplus1pm 2023-03-18 17:16:59 switch_source MQTT
setstate MQTT2_shellyplus1pm 2023-03-18 17:16:59 switch_voltage 226.8
setstate MQTT2_shellyplus1pm 2023-03-18 14:08:13 sys_cfg_rev 28
setstate MQTT2_shellyplus1pm 2023-03-18 14:08:13 sys_fs_free 98304
setstate MQTT2_shellyplus1pm 2023-03-18 14:08:13 sys_fs_size 458752
setstate MQTT2_shellyplus1pm 2023-03-18 14:08:13 sys_kvs_rev 2
setstate MQTT2_shellyplus1pm 2023-03-18 14:08:13 sys_mac 4855199CB07C
setstate MQTT2_shellyplus1pm 2023-03-18 14:08:13 sys_ram_free 159840
setstate MQTT2_shellyplus1pm 2023-03-18 14:08:13 sys_ram_size 234620
setstate MQTT2_shellyplus1pm 2023-03-18 14:08:13 sys_restart_required false
setstate MQTT2_shellyplus1pm 2023-03-18 14:08:13 sys_schedule_rev 0
setstate MQTT2_shellyplus1pm 2023-03-18 14:08:13 sys_time 14:08
setstate MQTT2_shellyplus1pm 2023-03-18 14:08:13 sys_unixtime 1679144894
setstate MQTT2_shellyplus1pm 2023-03-18 14:08:13 sys_uptime 14
setstate MQTT2_shellyplus1pm 2023-03-18 14:08:13 sys_webhook_rev 0
setstate MQTT2_shellyplus1pm 2023-03-18 17:16:59 temperature 27.8
setstate MQTT2_shellyplus1pm 2023-03-18 13:22:31 x_reboot set



Der Shelly ist über MQTT2_Server angebunden. Autocreate ist complex. Die MQTT Einstellungen des Shelly hab ich angehangen. FHEM update nothing to do. Hab ich was vergessen?

Wie komme ich an die nötigen Readings, damit der grüne Punkt wieder funktioniert?

Vielen Dank

oelidoc

Beta-User

Tja, sieht so aus, als würde der Shelly seine IP-Adresse (wg. firwareänderung?) nicht (mehr? automatisch?) per MQTT preisgeben. Ggf. mal auf der Doku-Seite des Herstellers schauen, ob man die abfragen kann, ansonsten bleibt nur der Weg, ggf. das Internal auszuwerten, das der MQTT2_SERVER dazu bereitstellt (wird an anderer Stelle auch so gemacht, ich hab's aber grade nicht parat und finde das auch nicht unbedingt wichtig).
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

oelidoc

Hallo Beta-User,
vielen Dank für deine Anregung: ich habe bei Shelly Facebook ein script gefunden, mit dem die IP übertragen wird.
Wen´s interessiert:

let device_info = Shelly.getDeviceInfo();
device_info["ip"] = "";

//Read ip from status
Shelly.call("WiFi.GetStatus", null, function (status) {
  if (status.status === "got ip") {
    device_info["ip"] = status.sta_ip;
  }
});

//Monitor ip changes
Shelly.addStatusHandler(function (status) {
  if (status.component === "wifi" && status.delta.status === "got ip") {
    device_info["ip"] = status.delta.sta_ip;
  }
});

Shelly.addEventHandler(function (ev_data) {
  let ev = ev_data.info;
  if (ev.component !== "mqtt") return;
  if (ev.event === "connected") {
    MQTT.publish(device_info.id + "/announce", JSON.stringify(device_info), 1, false);
  }
});

MQTT.subscribe(
  "shellies/command",
  function (topic, message, ud) {
    if (message === "announce") {
      MQTT.publish(device_info.id + "/announce", JSON.stringify(device_info), 1, false);
    }
  },
  null
);

Gruß

oelidoc