Ich habe einen Shell yPro2 via MQTT2 angebunden. Diesen steure ich per set on, set off, set on-for-timer an.
In Perl würde ich gerne abfragen, welchen Zustand der Shelly gerade hat. Leider wird nur on bzw. off geliefert. Bei einem set on-for-timer geht das Status-Attribut ganz kurz in den Status set_on-for-timer und dann sofort in den Status on.
Wie kann ich die drei Zustände unterscheiden?
Im "list <name>" sollte nach einem "set on-for-timer" ein Abschnitt erscheinen:
TIMED_OnOff:
CMD on-for-timer
DURATION 300
NEXTCMD off
START 1790700973.8377
START_FMT 2026-09-29 18:56:13
hash:
Das entspricht $defs{name}{TIMED_OnOff}
Das taucht dort leider nicht auf.
Vielleicht frage ich auch nicht schnell genug ab, denn im "state"-Attribut sieht man nur ganz kurz "set_on-for-timer", bis das Attribut auf "on" wechselt. Nach Ablauf der Zeit wechselt das Attribut dann wieder auf "off".
Ein "list <name>" liefert:
Internals:
CID ShellyPro2_CarportLicht
DEF ShellyPro2_CarportLicht
FUUID 6aa38c9d-f33f-2cfb-1a05-4247de9f3a8b155f
IODev MQTT2
LASTInputDev MQTT2
MQTT2_CONN MQTT2_192.168.179.25_50179
MQTT2_MSGCNT 226
MQTT2_TIME 2026-09-29 19:32:04
MSGCNT 226
NAME ShellyPro2_CarportLicht
NR 1939
STATE on
TYPE MQTT2_DEVICE
eventCount 222
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:
2026-09-29 18:53:44 IODev MQTT2
2026-09-11 07:09:23 associatedWith ShellyPro2_CarportLicht_CH2,ShellyPro2_CarportLicht_CH3,ShellyPro2_CarportLicht_CH4
2026-09-11 07:09:50 attrTemplateVersion 20240627
2026-09-29 18:54:11 ble {}
2026-09-29 18:54:11 bthome {}
2026-09-29 19:32:04 dst ShellyPro2-CarportLicht/events
2026-09-29 18:54:11 input_1_id 1
2026-09-29 18:54:11 input_1_state false
2026-09-29 18:54:11 input_id 0
2026-09-29 18:54:11 input_state false
2026-09-29 18:54:11 ip 192.168.179.25
2026-09-29 18:54:11 knx {}
2026-09-29 19:32:04 method NotifyStatus
2026-09-29 18:54:11 modbus {}
2026-09-29 18:54:11 mqtt_connected true
2026-09-29 18:54:11 online true
2026-09-29 18:54:11 params_cloud_connected false
2026-09-29 18:54:11 params_input_0_id 0
2026-09-29 18:54:11 params_input_0_state false
2026-09-29 18:54:11 params_input_1_id 1
2026-09-29 18:54:11 params_input_1_state false
2026-09-29 18:54:11 params_mqtt_connected true
2026-09-29 19:32:00 params_switch_0_counts_on_time 82440
2026-09-29 18:54:11 params_switch_0_counts_on_time_rst_ts 0
2026-09-29 19:32:00 params_switch_0_counts_switch_on 137
2026-09-29 18:54:11 params_switch_0_counts_switch_on_rst_ts 0
2026-09-29 18:54:11 params_switch_0_id 0
2026-09-29 19:32:04 params_switch_0_output true
2026-09-29 19:32:04 params_switch_0_source MQTT
2026-09-29 19:32:04 params_switch_0_timer_duration 111.00
2026-09-29 19:32:04 params_switch_0_timer_started_at 1790703123.69
2026-09-29 19:32:00 params_switch_1_counts_on_time 0
2026-09-29 18:54:11 params_switch_1_counts_on_time_rst_ts 0
2026-09-29 19:32:00 params_switch_1_counts_switch_on 5
2026-09-29 18:54:11 params_switch_1_counts_switch_on_rst_ts 0
2026-09-29 18:54:11 params_switch_1_id 1
2026-09-29 18:54:11 params_switch_1_output false
2026-09-29 18:54:11 params_switch_1_source init
2026-09-29 18:54:11 params_switch_1_temperature_tC 36.6
2026-09-29 18:54:11 params_switch_1_temperature_tF 97.8
2026-09-17 14:59:50 params_sys_alt_Pro2ProAddon_beta_build_id 20260917-100714/2.0.1-beta3-g31658db
2026-09-17 14:59:50 params_sys_alt_Pro2ProAddon_beta_version 2.0.1-beta3
2026-09-29 18:54:11 params_sys_alt_Pro2ProAddon_desc Pro 2 with Pro Sensor Addon
2026-09-29 18:54:11 params_sys_alt_Pro2ProAddon_name Shelly Pro 2
2026-09-29 18:54:11 params_sys_alt_Pro2ProAddon_stable_build_id 20260923-075709/2.0.1-ge1a198b
2026-09-29 18:54:11 params_sys_alt_Pro2ProAddon_stable_version 2.0.1
2026-09-17 14:59:50 params_sys_available_updates_beta_version 2.0.1-beta3
2026-09-29 18:54:11 params_sys_available_updates_stable_version 2.0.1
2026-09-29 18:54:11 params_sys_bthc_rev 0
2026-09-29 18:54:11 params_sys_btrelay_rev 0
2026-09-29 18:54:11 params_sys_cfg_rev 20
2026-09-29 18:54:11 params_sys_fs_free 155648
2026-09-29 18:54:11 params_sys_fs_size 524288
2026-09-29 18:54:11 params_sys_kvs_rev 0
2026-09-29 19:07:03 params_sys_last_sync_ts 1790701623
2026-09-29 18:54:11 params_sys_mac 80F3DAC92644
2026-09-29 18:54:11 params_sys_ram_free 133372
2026-09-29 18:54:11 params_sys_ram_min_free 116060
2026-09-29 18:54:11 params_sys_ram_size 266356
2026-09-29 18:54:11 params_sys_reset_reason 1
2026-09-29 18:54:11 params_sys_restart_required false
2026-09-29 18:54:11 params_sys_schedule_rev 0
2026-09-29 19:07:04 params_sys_time 19:07
2026-09-29 19:07:04 params_sys_unixtime 1790701623
2026-09-29 18:54:11 params_sys_uptime 268310
2026-09-29 18:54:11 params_sys_utc_offset 7200
2026-09-29 18:54:11 params_sys_webhook_rev 0
2026-09-29 19:32:04 params_ts 1790703123.69
2026-09-29 18:54:11 params_wifi_bssid f0:9f:c2:24:18:f9
2026-09-29 18:54:11 params_wifi_channel 1
2026-09-29 18:54:11 params_wifi_rssi -67
2026-09-29 18:54:11 params_wifi_ssid Quadratogramm
2026-09-29 18:54:11 params_wifi_sta_ip6_1 fe80::82f3:daff:fec9:2644
2026-09-29 18:54:11 params_wifi_status got ip
2026-09-29 18:54:11 params_ws_connected false
2026-09-29 19:32:04 rpc_dst ShellyPro2-CarportLicht/events
2026-09-29 19:32:04 rpc_method NotifyStatus
2026-09-29 18:54:11 rpc_params_cloud_connected false
2026-09-29 18:54:11 rpc_params_input_0_id 0
2026-09-29 18:54:11 rpc_params_input_0_state false
2026-09-29 18:54:11 rpc_params_input_1_id 1
2026-09-29 18:54:11 rpc_params_input_1_state false
2026-09-29 18:54:11 rpc_params_mqtt_connected true
2026-09-29 19:32:00 rpc_params_switch_0_counts_on_time 82440
2026-09-29 18:54:11 rpc_params_switch_0_counts_on_time_rst_ts 0
2026-09-29 19:32:00 rpc_params_switch_0_counts_switch_on 137
2026-09-29 18:54:11 rpc_params_switch_0_counts_switch_on_rst_ts 0
2026-09-29 18:54:11 rpc_params_switch_0_id 0
2026-09-29 19:32:04 rpc_params_switch_0_output true
2026-09-29 19:32:04 rpc_params_switch_0_source MQTT
2026-09-29 18:54:11 rpc_params_switch_0_temperature_tC 31.4
2026-09-29 18:54:11 rpc_params_switch_0_temperature_tF 88.5
2026-09-29 19:32:04 rpc_params_switch_0_timer_duration 111.00
2026-09-29 19:32:04 rpc_params_switch_0_timer_started_at 1790703123.69
2026-09-29 19:32:00 rpc_params_switch_1_counts_on_time 0
2026-09-29 18:54:11 rpc_params_switch_1_counts_on_time_rst_ts 0
2026-09-29 19:32:00 rpc_params_switch_1_counts_switch_on 5
2026-09-29 18:54:11 rpc_params_switch_1_counts_switch_on_rst_ts 0
2026-09-29 18:54:11 rpc_params_switch_1_id 1
2026-09-29 18:54:11 rpc_params_switch_1_output false
2026-09-29 18:54:11 rpc_params_switch_1_source init
2026-09-29 18:54:11 rpc_params_switch_1_temperature_tC 36.6
2026-09-29 18:54:11 rpc_params_switch_1_temperature_tF 97.8
2026-09-17 14:59:50 rpc_params_sys_alt_Pro2ProAddon_beta_build_id 20260917-100714/2.0.1-beta3-g31658db
2026-09-17 14:59:50 rpc_params_sys_alt_Pro2ProAddon_beta_version 2.0.1-beta3
2026-09-29 18:54:11 rpc_params_sys_alt_Pro2ProAddon_desc Pro 2 with Pro Sensor Addon
2026-09-29 18:54:11 rpc_params_sys_alt_Pro2ProAddon_name Shelly Pro 2
2026-09-29 18:54:11 rpc_params_sys_alt_Pro2ProAddon_stable_build_id 20260923-075709/2.0.1-ge1a198b
2026-09-29 18:54:11 rpc_params_sys_alt_Pro2ProAddon_stable_version 2.0.1
2026-09-17 14:59:50 rpc_params_sys_available_updates_beta_version 2.0.1-beta3
2026-09-29 18:54:11 rpc_params_sys_available_updates_stable_version 2.0.1
2026-09-29 18:54:11 rpc_params_sys_bthc_rev 0
2026-09-29 18:54:11 rpc_params_sys_btrelay_rev 0
2026-09-29 18:54:11 rpc_params_sys_cfg_rev 20
2026-09-29 18:54:11 rpc_params_sys_fs_free 155648
2026-09-29 18:54:11 rpc_params_sys_fs_size 524288
2026-09-29 18:54:11 rpc_params_sys_kvs_rev 0
2026-09-29 19:07:03 rpc_params_sys_last_sync_ts 1790701623
2026-09-29 18:54:11 rpc_params_sys_mac 80F3DAC92644
2026-09-29 18:54:11 rpc_params_sys_ram_free 133372
2026-09-29 18:54:11 rpc_params_sys_ram_min_free 116060
2026-09-29 18:54:11 rpc_params_sys_ram_size 266356
2026-09-29 18:54:11 rpc_params_sys_reset_reason 1
2026-09-29 18:54:11 rpc_params_sys_restart_required false
2026-09-29 18:54:11 rpc_params_sys_schedule_rev 0
2026-09-29 19:07:04 rpc_params_sys_time 19:07
2026-09-29 19:07:04 rpc_params_sys_unixtime 1790701623
2026-09-29 18:54:11 rpc_params_sys_uptime 268310
2026-09-29 18:54:11 rpc_params_sys_utc_offset 7200
2026-09-29 18:54:11 rpc_params_sys_webhook_rev 0
2026-09-29 19:32:04 rpc_params_ts 1790703123.69
2026-09-29 18:54:11 rpc_params_wifi_bssid f0:9f:c2:24:18:f9
2026-09-29 18:54:11 rpc_params_wifi_channel 1
2026-09-29 18:54:11 rpc_params_wifi_rssi -67
2026-09-29 18:54:11 rpc_params_wifi_ssid Quadratogramm
2026-09-29 18:54:11 rpc_params_wifi_sta_ip 192.168.179.25
2026-09-29 18:54:11 rpc_params_wifi_sta_ip6_1 fe80::82f3:daff:fec9:2644
2026-09-29 18:54:11 rpc_params_wifi_status got ip
2026-09-29 18:54:11 rpc_params_ws_connected false
2026-09-29 19:32:04 rpc_src shellypro2-80f3dac92644
2026-09-29 19:32:04 src shellypro2-80f3dac92644
2026-09-29 19:32:03 state on
2026-09-29 18:55:57 statusRequest set set set set set set set set set set set set set set set
2026-09-29 19:32:03 switch_0_counts_on_time 82440
2026-09-29 19:32:03 switch_0_counts_on_time_rst_ts 0
2026-09-29 19:32:03 switch_0_counts_switch_on 138
2026-09-29 19:32:03 switch_0_counts_switch_on_rst_ts 0
2026-09-29 19:32:03 switch_0_id 0
2026-09-29 19:32:03 switch_0_output true
2026-09-29 19:32:03 switch_0_source MQTT
2026-09-29 19:32:03 switch_0_temperature_tC 32.2
2026-09-29 19:32:03 switch_0_temperature_tF 90.0
2026-09-29 19:32:03 switch_0_timer_duration 111.00
2026-09-29 19:32:03 switch_0_timer_remaining 110
2026-09-29 19:32:03 switch_0_timer_started_at 1790703123.69
2026-09-29 19:32:00 switch_1_counts_on_time 0
2026-09-29 19:32:00 switch_1_counts_on_time_rst_ts 0
2026-09-29 19:32:00 switch_1_counts_switch_on 5
2026-09-29 19:32:00 switch_1_counts_switch_on_rst_ts 0
2026-09-29 19:32:00 switch_1_id 1
2026-09-29 19:32:00 switch_1_output false
2026-09-29 19:32:00 switch_1_source init
2026-09-29 19:32:00 switch_1_temperature_tC 36.1
2026-09-29 19:32:00 switch_1_temperature_tF 97.0
2026-09-29 19:32:03 switch_counts_on_time 82440
2026-09-29 19:32:03 switch_counts_on_time_rst_ts 0
2026-09-29 19:32:03 switch_counts_switch_on 138
2026-09-29 19:32:03 switch_counts_switch_on_rst_ts 0
2026-09-29 19:32:03 switch_id 0
2026-09-29 19:32:03 switch_source MQTT
2026-09-29 19:32:03 switch_timer_duration 111.00
2026-09-29 19:32:03 switch_timer_started_at 1790703123.69
2026-09-24 11:52:59 sys_alt_Pro2ProAddon_beta_build_id 20260917-100714/2.0.1-beta3-g31658db
2026-09-24 11:52:59 sys_alt_Pro2ProAddon_beta_version 2.0.1-beta3
2026-09-29 19:07:04 sys_alt_Pro2ProAddon_desc Pro 2 with Pro Sensor Addon
2026-09-29 19:07:04 sys_alt_Pro2ProAddon_name Shelly Pro 2
2026-09-29 19:07:04 sys_alt_Pro2ProAddon_stable_build_id 20260923-075709/2.0.1-ge1a198b
2026-09-29 19:07:04 sys_alt_Pro2ProAddon_stable_version 2.0.1
2026-09-24 11:52:59 sys_available_updates_beta_version 2.0.1-beta3
2026-09-29 19:07:04 sys_available_updates_stable_version 2.0.1
2026-09-29 19:07:04 sys_bthc_rev 0
2026-09-29 19:07:04 sys_btrelay_rev 0
2026-09-29 19:07:04 sys_cfg_rev 20
2026-09-29 19:07:04 sys_fs_free 155648
2026-09-29 19:07:04 sys_fs_size 524288
2026-09-29 19:07:04 sys_kvs_rev 0
2026-09-29 19:07:04 sys_last_sync_ts 1790701623
2026-09-29 19:07:04 sys_mac 80F3DAC92644
2026-09-29 19:07:04 sys_ram_free 133208
2026-09-29 19:07:04 sys_ram_min_free 116060
2026-09-29 19:07:04 sys_ram_size 266360
2026-09-29 19:07:04 sys_reset_reason 1
2026-09-29 19:07:04 sys_restart_required false
2026-09-29 19:07:04 sys_schedule_rev 0
2026-09-29 19:07:04 sys_time 19:07
2026-09-29 19:07:04 sys_unixtime 1790701623
2026-09-29 19:07:04 sys_uptime 269083
2026-09-29 19:07:04 sys_utc_offset 7200
2026-09-29 19:07:04 sys_webhook_rev 0
2026-09-29 19:32:03 temperature 32.2
2026-09-29 18:54:11 wifi_bssid f0:9f:c2:24:18:f9
2026-09-29 18:54:11 wifi_channel 1
2026-09-29 18:54:11 wifi_rssi -67
2026-09-29 18:54:11 wifi_ssid Quadratogramm
2026-09-29 18:54:11 wifi_sta_ip 192.168.179.25
2026-09-29 18:54:11 wifi_sta_ip6_1 fe80::82f3:daff:fec9:2644
2026-09-29 18:54:11 wifi_status got ip
2026-09-29 18:54:11 ws_connected false
2026-09-11 07:09:50 x_reboot set
hmccu:
Attributes:
comment Channel 1 for ShellyPro2_CarportLicht, see also ShellyPro2_CarportLicht_CH2, ShellyPro2_CarportLicht_CH3 and ShellyPro2_CarportLicht_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-CarportLicht
getList in_mode:noArg in_mode $DEVICETOPIC/rpc {"id": 1,"src":"$DEVICETOPIC", "method": "Switch.GetConfig", "params": {"id": 0}}
icon off
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_CarportLicht:ShellyPro2-CarportLicht/events/rpc:.* { json2nameValue($EVENT, 'rpc_', $JSONMAP) }
ShellyPro2_CarportLicht:ShellyPro2-CarportLicht/status/switch_1:.* { json2nameValue($EVENT, 'switch_1_', $JSONMAP) }
ShellyPro2_CarportLicht:ShellyPro2-CarportLicht/status/switch_0:.* { json2nameValue($EVENT, 'switch_0_', $JSONMAP) }
ShellyPro2_CarportLicht:ShellyPro2-CarportLicht/status/ble:.* ble
ShellyPro2_CarportLicht:ShellyPro2-CarportLicht/status/bthome:.* bthome
ShellyPro2_CarportLicht:ShellyPro2-CarportLicht/status/eth:.* { json2nameValue($EVENT, 'eth_', $JSONMAP) }
ShellyPro2_CarportLicht:ShellyPro2-CarportLicht/status/input_1:.* { json2nameValue($EVENT, 'input_1_', $JSONMAP) }
ShellyPro2_CarportLicht:ShellyPro2-CarportLicht/status/knx:.* knx
ShellyPro2_CarportLicht:ShellyPro2-CarportLicht/status/modbus:.* modbus
ShellyPro2_CarportLicht:ShellyPro2-CarportLicht/status/wifi:.* { json2nameValue($EVENT, 'wifi_', $JSONMAP) }
ShellyPro2_CarportLicht:ShellyPro2-CarportLicht/status/ws:.* { json2nameValue($EVENT, 'ws_', $JSONMAP) }
room Aussen,Lampen,MQTT,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
userReadings switch_0_timer_remaining:switch_0_timer_started_at.* {
my $started = ReadingsNum("ShellyPro2_CarportLicht", "switch_0_timer_started_at", 0);
my $duration = ReadingsNum("ShellyPro2_CarportLicht", "switch_0_timer_duration", 0);
return 0 if ($started == 0 || $duration == 0);
my $remaining = int(($started + $duration) - time());
return $remaining > 0 ? $remaining : 0;
}
webCmd :
Auch meine anderen Shellys zeigen kein TIMED_OnOff (Shelly Pro4pm).
Gibt es irgen deine Möglichkeit, herauszufinden, ob der Shelly im Timer läuft?