[gelöst]devStateIcon mit stateFormat, cmd funktioniert nicht

Begonnen von frober, 22 Oktober 2023, 18:30:30

Vorheriges Thema - Nächstes Thema

frober

Hallo zusammen,

ich habe mehrere Sonoff Basic mit Tasmota als PIR (abgekoppelt) in Verwendung.

Das STATE zeigt per Text und SVG den Zustand der Lampe und des PIRs an (siehe Anhang).
Aus Gewohnheit drücke ich auf das SVG der Lampe, dabei wird diese auch eingeschaltet (auch ohne das devStateIcon definiert war).
Das Ausschalten funktionierte leider nicht. Daher habe ich devStateIcon definiert:
attr Sonoff_PIR2 devStateIcon on:light_outdoor@yellow:off off:light_outdoor@black:on
In Verbindung mit stateFormat funktioniert das so leider nicht.
attr Sonoff_PIR2 stateFormat {\
  my $state = ReadingsVal($name, "POWER", "OFF");;\
  my $pir   = ReadingsVal($name, "Motion", "OFF");;\
  return '<div>  Licht: '.FW_makeImage('light_outdoor@yellow','on').'  Bewegung: '.FW_makeImage('motion_detector@red','Motion').'</div>' if($state eq "ON" && $pir eq "ON");;\
  return '<div>  Licht: '.FW_makeImage('light_outdoor@black','off').'  Bewegung: '.FW_makeImage('motion_detector@red','Motion').'</div>' if($state eq "OFF" && $pir eq "ON");;\
  return '<div>  Licht: '.FW_makeImage('light_outdoor@black','off').'  Bewegung: '.FW_makeImage('motion_detector@green','no Motion').'</div>' if($state eq "OFF" && $pir eq "OFF");;\
  return '<div>  Licht: '.FW_makeImage('light_outdoor@yellow','on').'  Bewegung: '.FW_makeImage('motion_detector@green','no Motion').'</div>' if($state eq "ON" && $pir eq "OFF");;\
}

Wie muss ich jetzt vorgehen, bzw. was wäre die beste/einfachste Lösung?

Hier das komlette List:
define Sonoff_PIR2 MQTT2_DEVICE DVES_5783CC
attr Sonoff_PIR2 IODev MQTT2_Server
attr Sonoff_PIR2 alias Hoflicht Werkstatt
attr Sonoff_PIR2 autocreate 0
attr Sonoff_PIR2 comment Licht + Bewegungsmelder Werkstatt aussen
attr Sonoff_PIR2 devStateIcon on:light_outdoor@yellow:off off:light_outdoor@black:on
attr Sonoff_PIR2 event-on-change-reading .*
attr Sonoff_PIR2 model Sonoff Basic
attr Sonoff_PIR2 readingList DVES_5783CC:tele/Sonoff_PIR2/INFO1:.* { json2nameValue($EVENT) }\
DVES_5783CC:stat/Sonoff_PIR2/RESULT:.* { json2nameValue($EVENT) }\
DVES_5783CC:stat/Sonoff_PIR2/POWER:.* POWER\
DVES_5783CC:tele/Sonoff_PIR2/STATE:.* { json2nameValue($EVENT) }\
DVES_5783CC:tele/Sonoff_PIR2/LWT:.* LWT\
DVES_5783CC:cmnd/Alarm_SO2/POWER1:.* Motion
attr Sonoff_PIR2 room Haus->Aussen
attr Sonoff_PIR2 setList on   cmnd/Sonoff_PIR2/POWER 1 \
off  cmnd/Sonoff_PIR2/POWER 0
attr Sonoff_PIR2 stateFormat {\
  my $state = ReadingsVal($name, "POWER", "OFF");;\
  my $pir   = ReadingsVal($name, "Motion", "OFF");;\
  return '<div>  Licht: '.FW_makeImage('light_outdoor@yellow','on').'  Bewegung: '.FW_makeImage('motion_detector@red','Motion').'</div>' if($state eq "ON" && $pir eq "ON");;\
  return '<div>  Licht: '.FW_makeImage('light_outdoor@black','off').'  Bewegung: '.FW_makeImage('motion_detector@red','Motion').'</div>' if($state eq "OFF" && $pir eq "ON");;\
  return '<div>  Licht: '.FW_makeImage('light_outdoor@black','off').'  Bewegung: '.FW_makeImage('motion_detector@green','no Motion').'</div>' if($state eq "OFF" && $pir eq "OFF");;\
  return '<div>  Licht: '.FW_makeImage('light_outdoor@yellow','on').'  Bewegung: '.FW_makeImage('motion_detector@green','no Motion').'</div>' if($state eq "ON" && $pir eq "OFF");;\
}
attr Sonoff_PIR2 webCmd on:off
#   CID        DVES_5783CC
#   DEF        DVES_5783CC
#   FUUID      6367e6f2-f33f-ff70-24b5-a18939c0fe7b83e9
#   IODev      MQTT2_Server
#   LASTInputDev MQTT2_Server
#   MQTT2_Server_CONN MQTT2_Server_192.168.10.51_23171
#   MQTT2_Server_MSGCNT 2797
#   MQTT2_Server_TIME 2023-10-22 18:18:25
#   MSGCNT     2797
#   NAME       Sonoff_PIR2
#   NR         556
#   STATE      <div>  Licht: <svg class=" light_outdoor black" data-txt="off" version="1.0" xmlns="http://www.w3.org/2000/svg"  width="468pt" height="470pt" viewBox="0 0 468 470"  preserveAspectRatio="xMidYMid meet"> <metadata> Created by potrace 1.8, written by Peter Selinger 2001-2007 </metadata> <g transform="translate(0,470) scale(0.158108,-0.158108)" fill="black" stroke="none"> <path d="M161 2947 c-51 -19 -106 -71 -132 -124 -24 -47 -24 -53 -27 -406 -4 -406 0 -436 65 -508 38 -42 99 -79 130 -79 12 0 8 -6 -15 -20 -39 -24 -44 -65 -9 -80 12 -5 104 -24 205 -41 175 -30 184 -30 203 -13 21 19 25 59 7 70 -7 4 -93 22 -193 40 l-180 32 157 1 c133 1 166 4 212 22 67 24 128 88 145 151 9 31 11 154 9 424 l-3 381 -30 49 c-19 30 -49 60 -79 79 l-49 30 -191 2 c-133 1 -201 -2 -225 -10z m389 -132 c59 -30 60 -40 60 -420 0 -459 13 -435 -232 -435 -170 0 -195 6 -221 50 -15 25 -17 70 -17 385 0 233 4 363 11 376 5 11 25 29 42 39 28 17 51 20 180 20 113 0 155 -4 177 -15z"/> <path d="M2143 2412 c-500 -379 -726 -556 -734 -575 -15 -36 0 -73 37 -87 14 -6 63 -10 109 -10 l85 0 2 -814 c3 -803 3 -815 24 -843 11 -15 42 -39 70 -53 l49 -25 484 -3 c329 -2 502 1 538 8 57 12 118 56 133 94 4 12 9 650 11 1419 l4 1399 -24 19 c-13 10 -33 19 -45 19 -12 0 -320 -227 -743 -548z m665 -1469 l-3 -798 -42 -3 -42 -3 -3 490 -3 491 -38 37 -37 38 -205 3 c-230 4 -258 -2 -295 -63 -19 -31 -20 -49 -20 -514 l0 -481 -154 0 c-85 0 -161 3 -170 6 -14 6 -16 85 -16 800 l0 794 515 0 515 0 -2 -797z m-220 -335 l2 -458 -170 0 -170 0 0 460 0 460 168 -2 167 -3 3 -457z"/> <path d="M166 1668 c-39 -55 -18 -65 202 -104 167 -29 189 -31 210 -18 24 16 30 55 10 72 -11 8 -360 72 -395 72 -6 0 -19 -10 -27 -22z"/> <path d="M183 1559 c-26 -9 -38 -42 -24 -67 14 -26 402 -92 426 -72 17 14 20 66 5 75 -23 14 -387 71 -407 64z"/> <path d="M242 1418 c-16 -16 -15 -53 2 -67 8 -7 63 -20 123 -31 95 -16 111 -17 131 -4 24 16 30 55 10 72 -13 10 -187 42 -230 42 -13 0 -29 -5 -36 -12z"/> <path d="M116 824 c-11 -10 -16 -34 -16 -70 0 -48 -2 -54 -21 -54 -36 0 -59 -19 -59 -48 0 -36 17 -52 52 -52 l28 0 0 -170 0 -170 -35 0 c-33 0 -55 -20 -55 -49 0 -20 40 -51 65 -51 23 0 25 -3 25 -52 0 -60 6 -72 37 -82 36 -11 63 24 63 84 0 47 2 50 25 50 24 0 25 -3 25 -53 0 -54 19 -87 48 -87 29 0 52 40 52 90 0 47 2 50 25 50 24 0 25 -3 25 -53 0 -42 5 -58 21 -73 19 -17 23 -17 47 -3 24 13 27 22 30 72 3 53 5 57 27 57 22 0 24 -4 27 -57 3 -50 6 -59 30 -72 24 -14 28 -14 47 3 16 15 21 31 21 73 0 50 1 53 25 53 23 0 25 -3 25 -50 0 -37 5 -55 20 -70 24 -24 29 -24 58 -4 18 12 22 25 22 70 0 51 1 54 25 54 23 0 25 -3 25 -50 0 -37 5 -55 20 -70 43 -43 80 -13 80 66 0 51 1 54 25 54 23 0 25 -3 25 -50 0 -37 5 -55 20 -70 23 -23 33 -24 61 -10 15 9 19 22 19 70 0 60 0 60 30 60 l30 0 0 -60 c0 -54 3 -62 24 -71 17 -8 29 -8 45 0 18 10 21 21 21 71 0 60 0 60 30 60 l30 0 0 -60 c0 -54 3 -62 24 -71 17 -8 29 -8 45 0 18 10 21 21 21 70 0 56 2 60 29 69 15 5 31 19 33 30 7 27 -17 62 -43 62 -18 0 -19 8 -19 169 l0 169 24 6 c27 7 41 35 31 66 -3 11 -17 23 -31 26 -22 6 -24 11 -24 65 0 53 -3 61 -24 70 -17 8 -29 8 -45 0 -18 -10 -21 -21 -21 -71 0 -60 0 -60 -30 -60 l-30 0 0 60 c0 54 -3 62 -24 71 -17 8 -29 8 -45 0 -18 -10 -21 -21 -21 -71 0 -60 0 -60 -30 -60 l-30 0 0 60 c0 56 -2 61 -26 70 -29 11 -58 0 -68 -26 -3 -8 -6 -36 -6 -60 0 -40 -2 -44 -25 -44 -23 0 -25 3 -25 53 0 59 -6 71 -37 81 -36 11 -63 -24 -63 -84 0 -47 -2 -50 -25 -50 -24 0 -25 3 -25 53 0 54 -19 87 -48 87 -29 0 -52 -40 -52 -90 0 -47 -2 -50 -25 -50 -24 0 -25 3 -25 55 0 47 -3 57 -25 71 -23 15 -27 15 -50 0 -22 -14 -25 -24 -25 -71 0 -52 -1 -55 -25 -55 -24 0 -25 3 -25 55 0 47 -3 57 -25 71 -23 15 -27 15 -50 0 -22 -14 -25 -24 -25 -71 0 -52 -1 -55 -25 -55 -23 0 -25 3 -25 50 0 37 -5 55 -20 70 -24 24 -29 24 -58 4 -18 -12 -22 -25 -22 -70 0 -51 -1 -54 -25 -54 -23 0 -25 3 -25 50 0 73 -45 113 -84 74z m134 -394 l0 -170 -25 0 -25 0 0 170 0 170 25 0 25 0 0 -170z m150 0 l0 -170 -25 0 -25 0 0 170 0 170 25 0 25 0 0 -170z m150 0 l0 -170 -25 0 -25 0 0 170 0 170 25 0 25 0 0 -170z m150 0 l0 -170 -25 0 -25 0 0 170 0 170 25 0 25 0 0 -170z m150 0 l0 -170 -25 0 -25 0 0 170 0 170 25 0 25 0 0 -170z m150 0 l0 -170 -25 0 -25 0 0 170 0 170 25 0 25 0 0 -170z m160 0 l0 -170 -30 0 -30 0 0 170 0 170 30 0 30 0 0 -170z m150 0 l0 -170 -30 0 -30 0 0 170 0 170 30 0 30 0 0 -170z"/> </g> </svg>  Bewegung: <svg class=" motion_detector green" data-txt="no Motion"    xmlns:dc="http://purl.org/dc/elements/1.1/"    xmlns:cc="http://creativecommons.org/ns#"    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"    xmlns:svg="http://www.w3.org/2000/svg"    xmlns="http://www.w3.org/2000/svg"    version="1.0"    width="468pt"    height="475pt"    viewBox="0 0 468 475"    id="svg2">   <defs      id="defs14" />   <metadata      id="metadata4"> Created by potrace 1.8, written by Peter Selinger 2001-2007 <rdf:RDF>   <cc:Work      rdf:about="">     <dc:format>image/svg+xml</dc:format>     <dc:type        rdf:resource="http://purl.org/dc/dcmitype/StillImage" />     <dc:title></dc:title>   </cc:Work> </rdf:RDF> </metadata>   <g      transform="matrix(-0.10635835,-0.10317139,0.10178565,-0.10780634,256.53927,529.08217)"      id="g6"      fill="green" stroke="none">     <path        d="m 919,2931 c -29,-29 -29,-30 -29,-150 0,-72 5,-131 12,-146 15,-34 56,-55 106,-55 37,0 40,-2 46,-32 20,-104 123,-232 228,-281 31,-15 88,-32 127,-39 198,-34 393,92 457,295 l 18,57 44,0 c 37,0 50,6 78,34 l 34,34 0,116 c 0,124 -11,165 -49,186 -13,6 -199,10 -531,10 l -512,0 -29,-29 z m 991,-161 0,-60 -445,0 -445,0 0,60 0,60 445,0 445,0 0,-60 z m -656,-233 c 9,-59 50,-144 87,-178 l 32,-30 -28,11 c -70,27 -132,87 -174,167 -32,64 -29,73 28,73 l 49,0 6,-43 z m 186,-72 c 0,-105 -1,-114 -17,-108 -61,22 -105,85 -122,176 l -8,47 73,0 74,0 0,-115 z m 186,73 c -10,-66 -52,-144 -90,-167 -18,-12 -36,-21 -40,-21 -3,0 -6,52 -6,115 l 0,115 71,0 72,0 -7,-42 z m 154,30 c -1,-52 -78,-154 -149,-200 -57,-35 -67,-36 -34,0 35,37 63,101 70,162 l 6,50 53,0 c 37,0 54,-4 54,-12 z"        id="path8" />     <path        d="M 555,1390 C 258,978 14,632 12,622 10,611 34,582 79,542 432,226 853,47 1332,8 1871,-35 2451,170 2861,549 l 73,67 -24,35 c -186,262 -1095,1485 -1106,1487 -8,2 -31,-11 -51,-28 -52,-46 -143,-87 -226,-100 -124,-22 -266,16 -363,95 -23,19 -48,35 -56,35 -7,0 -256,-338 -553,-750 z m 723,603 c 160,-59 362,-30 484,67 l 36,29 536,-728 c 295,-401 536,-734 536,-739 0,-6 -44,-47 -97,-92 C 2397,216 1950,51 1470,50 1301,50 1199,60 1046,91 721,158 350,350 110,574 c -30,28 -48,52 -43,59 3,7 240,337 526,734 l 519,721 50,-35 c 27,-20 80,-47 116,-60 z"        id="path10" />   </g> </svg></div>
#   TYPE       MQTT2_DEVICE
#   eventCount 2752
#   READINGS:
#     2023-10-22 18:18:25   Epoch           1697991504
#     2023-10-21 12:13:11   FallbackTopic   cmnd/DVES_5783CC_fb/
#     2023-10-21 12:13:11   GroupTopic      sonoffs
#     2023-10-22 18:18:25   Heap            17
#     2023-09-28 18:24:49   IODev           MQTT2_Server
#     2023-10-21 12:13:11   LWT             Online
#     2023-10-22 18:18:25   LoadAvg         19
#     2023-10-21 12:13:11   Module          Sonoff Basic
#     2023-10-22 18:09:45   Motion          OFF
#     2023-10-22 18:18:25   MqttCount       1
#     2023-10-22 18:18:25   POWER           OFF
#     2023-10-22 18:18:25   Sleep           50
#     2023-10-22 18:18:25   SleepMode       Dynamic
#     2023-10-22 18:18:25   Time            2023-10-22T17:18:24
#     2023-10-22 18:18:25   Uptime          1T06:05:18
#     2023-10-22 18:18:25   UptimeSec       108318
#     2023-10-21 12:13:11   Version         6.6.0.5(sonoff)
#     2023-10-22 18:18:25   Wifi_AP         1
#     2023-10-22 18:18:25   Wifi_BSSId      68:FF:7B:0E:40:C1
#     2023-10-22 18:18:25   Wifi_Channel    11
#     2023-10-22 18:18:25   Wifi_Downtime   0T00:00:04
#     2023-10-22 18:18:25   Wifi_LinkCount  1
#     2023-10-22 18:18:25   Wifi_RSSI       54
#     2023-10-22 18:18:25   Wifi_SSId       XBox10SH
#     2023-10-22 17:42:39   state           off
#     2023-10-21 20:45:17   subscriptions   cmnd/DVES_5783CC_fb/# cmnd/Sonoff_PIR2/# cmnd/sonoffs/#
#
setstate Sonoff_PIR2 <div>  Licht: <svg class=" light_outdoor black" data-txt="off" version="1.0" xmlns="http://www.w3.org/2000/svg"  width="468pt" height="470pt" viewBox="0 0 468 470"  preserveAspectRatio="xMidYMid meet"> <metadata> Created by potrace 1.8, written by Peter Selinger 2001-2007 </metadata> <g transform="translate(0,470) scale(0.158108,-0.158108)" fill="black" stroke="none"> <path d="M161 2947 c-51 -19 -106 -71 -132 -124 -24 -47 -24 -53 -27 -406 -4 -406 0 -436 65 -508 38 -42 99 -79 130 -79 12 0 8 -6 -15 -20 -39 -24 -44 -65 -9 -80 12 -5 104 -24 205 -41 175 -30 184 -30 203 -13 21 19 25 59 7 70 -7 4 -93 22 -193 40 l-180 32 157 1 c133 1 166 4 212 22 67 24 128 88 145 151 9 31 11 154 9 424 l-3 381 -30 49 c-19 30 -49 60 -79 79 l-49 30 -191 2 c-133 1 -201 -2 -225 -10z m389 -132 c59 -30 60 -40 60 -420 0 -459 13 -435 -232 -435 -170 0 -195 6 -221 50 -15 25 -17 70 -17 385 0 233 4 363 11 376 5 11 25 29 42 39 28 17 51 20 180 20 113 0 155 -4 177 -15z"/> <path d="M2143 2412 c-500 -379 -726 -556 -734 -575 -15 -36 0 -73 37 -87 14 -6 63 -10 109 -10 l85 0 2 -814 c3 -803 3 -815 24 -843 11 -15 42 -39 70 -53 l49 -25 484 -3 c329 -2 502 1 538 8 57 12 118 56 133 94 4 12 9 650 11 1419 l4 1399 -24 19 c-13 10 -33 19 -45 19 -12 0 -320 -227 -743 -548z m665 -1469 l-3 -798 -42 -3 -42 -3 -3 490 -3 491 -38 37 -37 38 -205 3 c-230 4 -258 -2 -295 -63 -19 -31 -20 -49 -20 -514 l0 -481 -154 0 c-85 0 -161 3 -170 6 -14 6 -16 85 -16 800 l0 794 515 0 515 0 -2 -797z m-220 -335 l2 -458 -170 0 -170 0 0 460 0 460 168 -2 167 -3 3 -457z"/> <path d="M166 1668 c-39 -55 -18 -65 202 -104 167 -29 189 -31 210 -18 24 16 30 55 10 72 -11 8 -360 72 -395 72 -6 0 -19 -10 -27 -22z"/> <path d="M183 1559 c-26 -9 -38 -42 -24 -67 14 -26 402 -92 426 -72 17 14 20 66 5 75 -23 14 -387 71 -407 64z"/> <path d="M242 1418 c-16 -16 -15 -53 2 -67 8 -7 63 -20 123 -31 95 -16 111 -17 131 -4 24 16 30 55 10 72 -13 10 -187 42 -230 42 -13 0 -29 -5 -36 -12z"/> <path d="M116 824 c-11 -10 -16 -34 -16 -70 0 -48 -2 -54 -21 -54 -36 0 -59 -19 -59 -48 0 -36 17 -52 52 -52 l28 0 0 -170 0 -170 -35 0 c-33 0 -55 -20 -55 -49 0 -20 40 -51 65 -51 23 0 25 -3 25 -52 0 -60 6 -72 37 -82 36 -11 63 24 63 84 0 47 2 50 25 50 24 0 25 -3 25 -53 0 -54 19 -87 48 -87 29 0 52 40 52 90 0 47 2 50 25 50 24 0 25 -3 25 -53 0 -42 5 -58 21 -73 19 -17 23 -17 47 -3 24 13 27 22 30 72 3 53 5 57 27 57 22 0 24 -4 27 -57 3 -50 6 -59 30 -72 24 -14 28 -14 47 3 16 15 21 31 21 73 0 50 1 53 25 53 23 0 25 -3 25 -50 0 -37 5 -55 20 -70 24 -24 29 -24 58 -4 18 12 22 25 22 70 0 51 1 54 25 54 23 0 25 -3 25 -50 0 -37 5 -55 20 -70 43 -43 80 -13 80 66 0 51 1 54 25 54 23 0 25 -3 25 -50 0 -37 5 -55 20 -70 23 -23 33 -24 61 -10 15 9 19 22 19 70 0 60 0 60 30 60 l30 0 0 -60 c0 -54 3 -62 24 -71 17 -8 29 -8 45 0 18 10 21 21 21 71 0 60 0 60 30 60 l30 0 0 -60 c0 -54 3 -62 24 -71 17 -8 29 -8 45 0 18 10 21 21 21 70 0 56 2 60 29 69 15 5 31 19 33 30 7 27 -17 62 -43 62 -18 0 -19 8 -19 169 l0 169 24 6 c27 7 41 35 31 66 -3 11 -17 23 -31 26 -22 6 -24 11 -24 65 0 53 -3 61 -24 70 -17 8 -29 8 -45 0 -18 -10 -21 -21 -21 -71 0 -60 0 -60 -30 -60 l-30 0 0 60 c0 54 -3 62 -24 71 -17 8 -29 8 -45 0 -18 -10 -21 -21 -21 -71 0 -60 0 -60 -30 -60 l-30 0 0 60 c0 56 -2 61 -26 70 -29 11 -58 0 -68 -26 -3 -8 -6 -36 -6 -60 0 -40 -2 -44 -25 -44 -23 0 -25 3 -25 53 0 59 -6 71 -37 81 -36 11 -63 -24 -63 -84 0 -47 -2 -50 -25 -50 -24 0 -25 3 -25 53 0 54 -19 87 -48 87 -29 0 -52 -40 -52 -90 0 -47 -2 -50 -25 -50 -24 0 -25 3 -25 55 0 47 -3 57 -25 71 -23 15 -27 15 -50 0 -22 -14 -25 -24 -25 -71 0 -52 -1 -55 -25 -55 -24 0 -25 3 -25 55 0 47 -3 57 -25 71 -23 15 -27 15 -50 0 -22 -14 -25 -24 -25 -71 0 -52 -1 -55 -25 -55 -23 0 -25 3 -25 50 0 37 -5 55 -20 70 -24 24 -29 24 -58 4 -18 -12 -22 -25 -22 -70 0 -51 -1 -54 -25 -54 -23 0 -25 3 -25 50 0 73 -45 113 -84 74z m134 -394 l0 -170 -25 0 -25 0 0 170 0 170 25 0 25 0 0 -170z m150 0 l0 -170 -25 0 -25 0 0 170 0 170 25 0 25 0 0 -170z m150 0 l0 -170 -25 0 -25 0 0 170 0 170 25 0 25 0 0 -170z m150 0 l0 -170 -25 0 -25 0 0 170 0 170 25 0 25 0 0 -170z m150 0 l0 -170 -25 0 -25 0 0 170 0 170 25 0 25 0 0 -170z m150 0 l0 -170 -25 0 -25 0 0 170 0 170 25 0 25 0 0 -170z m160 0 l0 -170 -30 0 -30 0 0 170 0 170 30 0 30 0 0 -170z m150 0 l0 -170 -30 0 -30 0 0 170 0 170 30 0 30 0 0 -170z"/> </g> </svg>  Bewegung: <svg class=" motion_detector green" data-txt="no Motion"    xmlns:dc="http://purl.org/dc/elements/1.1/"    xmlns:cc="http://creativecommons.org/ns#"    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"    xmlns:svg="http://www.w3.org/2000/svg"    xmlns="http://www.w3.org/2000/svg"    version="1.0"    width="468pt"    height="475pt"    viewBox="0 0 468 475"    id="svg2">   <defs      id="defs14" />   <metadata      id="metadata4"> Created by potrace 1.8, written by Peter Selinger 2001-2007 <rdf:RDF>   <cc:Work      rdf:about="">     <dc:format>image/svg+xml</dc:format>     <dc:type        rdf:resource="http://purl.org/dc/dcmitype/StillImage" />     <dc:title></dc:title>   </cc:Work> </rdf:RDF> </metadata>   <g      transform="matrix(-0.10635835,-0.10317139,0.10178565,-0.10780634,256.53927,529.08217)"      id="g6"      fill="green" stroke="none">     <path        d="m 919,2931 c -29,-29 -29,-30 -29,-150 0,-72 5,-131 12,-146 15,-34 56,-55 106,-55 37,0 40,-2 46,-32 20,-104 123,-232 228,-281 31,-15 88,-32 127,-39 198,-34 393,92 457,295 l 18,57 44,0 c 37,0 50,6 78,34 l 34,34 0,116 c 0,124 -11,165 -49,186 -13,6 -199,10 -531,10 l -512,0 -29,-29 z m 991,-161 0,-60 -445,0 -445,0 0,60 0,60 445,0 445,0 0,-60 z m -656,-233 c 9,-59 50,-144 87,-178 l 32,-30 -28,11 c -70,27 -132,87 -174,167 -32,64 -29,73 28,73 l 49,0 6,-43 z m 186,-72 c 0,-105 -1,-114 -17,-108 -61,22 -105,85 -122,176 l -8,47 73,0 74,0 0,-115 z m 186,73 c -10,-66 -52,-144 -90,-167 -18,-12 -36,-21 -40,-21 -3,0 -6,52 -6,115 l 0,115 71,0 72,0 -7,-42 z m 154,30 c -1,-52 -78,-154 -149,-200 -57,-35 -67,-36 -34,0 35,37 63,101 70,162 l 6,50 53,0 c 37,0 54,-4 54,-12 z"        id="path8" />     <path        d="M 555,1390 C 258,978 14,632 12,622 10,611 34,582 79,542 432,226 853,47 1332,8 1871,-35 2451,170 2861,549 l 73,67 -24,35 c -186,262 -1095,1485 -1106,1487 -8,2 -31,-11 -51,-28 -52,-46 -143,-87 -226,-100 -124,-22 -266,16 -363,95 -23,19 -48,35 -56,35 -7,0 -256,-338 -553,-750 z m 723,603 c 160,-59 362,-30 484,67 l 36,29 536,-728 c 295,-401 536,-734 536,-739 0,-6 -44,-47 -97,-92 C 2397,216 1950,51 1470,50 1301,50 1199,60 1046,91 721,158 350,350 110,574 c -30,28 -48,52 -43,59 3,7 240,337 526,734 l 519,721 50,-35 c 27,-20 80,-47 116,-60 z"        id="path10" />   </g> </svg></div>
setstate Sonoff_PIR2 2023-10-22 18:18:25 Epoch 1697991504
setstate Sonoff_PIR2 2023-10-21 12:13:11 FallbackTopic cmnd/DVES_5783CC_fb/
setstate Sonoff_PIR2 2023-10-21 12:13:11 GroupTopic sonoffs
setstate Sonoff_PIR2 2023-10-22 18:18:25 Heap 17
setstate Sonoff_PIR2 2023-09-28 18:24:49 IODev MQTT2_Server
setstate Sonoff_PIR2 2023-10-21 12:13:11 LWT Online
setstate Sonoff_PIR2 2023-10-22 18:18:25 LoadAvg 19
setstate Sonoff_PIR2 2023-10-21 12:13:11 Module Sonoff Basic
setstate Sonoff_PIR2 2023-10-22 18:09:45 Motion OFF
setstate Sonoff_PIR2 2023-10-22 18:18:25 MqttCount 1
setstate Sonoff_PIR2 2023-10-22 18:18:25 POWER OFF
setstate Sonoff_PIR2 2023-10-22 18:18:25 Sleep 50
setstate Sonoff_PIR2 2023-10-22 18:18:25 SleepMode Dynamic
setstate Sonoff_PIR2 2023-10-22 18:18:25 Time 2023-10-22T17:18:24
setstate Sonoff_PIR2 2023-10-22 18:18:25 Uptime 1T06:05:18
setstate Sonoff_PIR2 2023-10-22 18:18:25 UptimeSec 108318
setstate Sonoff_PIR2 2023-10-21 12:13:11 Version 6.6.0.5(sonoff)
setstate Sonoff_PIR2 2023-10-22 18:18:25 Wifi_AP 1
setstate Sonoff_PIR2 2023-10-22 18:18:25 Wifi_BSSId 68:FF:7B:0E:40:C1
setstate Sonoff_PIR2 2023-10-22 18:18:25 Wifi_Channel 11
setstate Sonoff_PIR2 2023-10-22 18:18:25 Wifi_Downtime 0T00:00:04
setstate Sonoff_PIR2 2023-10-22 18:18:25 Wifi_LinkCount 1
setstate Sonoff_PIR2 2023-10-22 18:18:25 Wifi_RSSI 54
setstate Sonoff_PIR2 2023-10-22 18:18:25 Wifi_SSId XBox10SH
setstate Sonoff_PIR2 2023-10-22 17:42:39 state off
setstate Sonoff_PIR2 2023-10-21 20:45:17 subscriptions cmnd/DVES_5783CC_fb/# cmnd/Sonoff_PIR2/# cmnd/sonoffs/#


Danke und Grüße
Raspi 3b mit Raspbian Bullseye und relativ aktuellem Fhem,  FS20, LGW, PCA301, Zigbee, MQTT, MySensors mit RS485(CAN-Receiver) und RFM69, etc.,
einiges umgesetzt, vieles in Planung, smile

********************************************
...man wächst mit der Herausforderung...

TomLee

attr Sonoff_PIR2 devStateIcon 1.ON:light_outdoor@yellow:off 1.OFF:light_outdoor@black:on\
2.ON:motion_detector@red:off 2.OFF:motion_detector@green:on

attr Sonoff_PIR2 stateFormat 1:POWER\
2:Motion

?

Wie/ob man jetzt in stateFormat noch Licht und Bewegung davorgeschrieben bekommt weiß ich nicht.

frober

Danke TomLee, die Version habe ich schon gesehen.
Mich interessiert eher wieso on funktioniert und off nicht.

Evtl. muss ich alles mit Perl ins devStateIcon verlegen. Das ist ja mittlerweile möglich.
Raspi 3b mit Raspbian Bullseye und relativ aktuellem Fhem,  FS20, LGW, PCA301, Zigbee, MQTT, MySensors mit RS485(CAN-Receiver) und RFM69, etc.,
einiges umgesetzt, vieles in Planung, smile

********************************************
...man wächst mit der Herausforderung...

TomLee

ZitatEvtl. muss ich alles mit Perl ins devStateIcon verlegen. Das ist ja mittlerweile möglich.

Nimm mal deinen Code aus stateFormat und schreib den einfach in devStateIcon, klappt doch dann oder nicht ?

frober

#4
Zitat von: TomLee am 22 Oktober 2023, 21:32:28Nimm mal deinen Code aus stateFormat und schreib den einfach in devStateIcon, klappt doch dann oder nicht ?

Da war ja einfach, danke.
Da habe ich wohl zu kompliziert gedacht.
stateFormat ist entsprechend gelöscht und wird nicht benötigt.
Raspi 3b mit Raspbian Bullseye und relativ aktuellem Fhem,  FS20, LGW, PCA301, Zigbee, MQTT, MySensors mit RS485(CAN-Receiver) und RFM69, etc.,
einiges umgesetzt, vieles in Planung, smile

********************************************
...man wächst mit der Herausforderung...

frober

Zur Vollständigkeit:
Der Perl-Code im stateFormat, der nun im devStateIcon ist, hatte ich auf die Schnelle geschrieben...

Hier nochmal eine Optimierung, falls es jemand gebrauchen kann:
attr Sonoff_PIR3 devStateIcon {\
 my $light = 'light_outdoor@green';;\
 $light = 'light_outdoor@yellow' if ReadingsVal($name, "POWER", "ON") eq 'ON';;\
 my $pir = 'motion_detector@green';;\
 $pir = 'motion_detector@red' if ReadingsVal($name, "Motion", "OFF") eq 'ON';;\
 return '<div> Licht: '.FW_makeImage($light,'on').' Bewegung: '.FW_makeImage($pir,'Motion').'</div>';;}
Raspi 3b mit Raspbian Bullseye und relativ aktuellem Fhem,  FS20, LGW, PCA301, Zigbee, MQTT, MySensors mit RS485(CAN-Receiver) und RFM69, etc.,
einiges umgesetzt, vieles in Planung, smile

********************************************
...man wächst mit der Herausforderung...

TomLee

#6
ZitatWie/ob man jetzt in stateFormat noch Licht und Bewegung davorgeschrieben bekommt weiß ich nicht.

Jetzt schon, ganz einfach, den "Text" (darf halt mit nix matchen) in eine Zeile davor schreiben:

attr Sonoff_PIR3 devStateIcon Licht.ON:light_outdoor@yellow:off Licht.OFF:light_outdoor@green:on Bewegung.ON:people_sensor@red Bewegung.OFF:people_sensor@green
attr Sonoff_PIR2 stateFormat Licht\
Licht:POWER\
Bewegung\
Bewegung:Motion

kürzer und auch zum Verständnis:
attr Sonoff_PIR2 devStateIcon 1.ON:light_outdoor@yellow:off 1.OFF:light_outdoor@green:on 2.ON:people_sensor@red 2.OFF:people_sensor@green
attr Sonoff_PIR2 stateFormat Licht\
1:POWER\
<br>\
Bewegung\
2:Motion