Hallo, ich versuche Daten von einem Gerät über Websocket einzulesen und bekomme dabei immer eine ganze Zeile Werte
Ich hätte gerne die Werte position für die zugehörige shadeId (davon gibt es mehrere von 0 bis 4 sind angelegt) und würde die in Reading bringen wollen
Internals:
DEF ws://192.168.10.89:8080
DeviceName ws:192.168.10.89:8080
FD 4
FUUID 65157e00-f33f-05ec-925b-ea374e8d5ac8da0f
NAME SomFy_RTS_02
NR 50
PARTIAL
STATE opened
TYPE UBUS_CLIENT
WEBSOCKET 1
eventCount 1
lastid 0
method websocket
session 00000000000000000000000000000000
READINGS:
2023-10-09 09:22:54 state opened
header:
Sec-WebSocket-Protocol ubus-json
helper:
rpc:
SomFy_RTS_02:call:0:
id SomFy_RTS_02:call:0
jsonrpc 2.0
method call
params:
00000000000000000000000000000000
session
login
HASH(0x38c4e80)
Attributes:
room SomFy
verbose 5
das notify dazu
Internals:
DEF SomFy_RTS_02:UNKNOWNCODE.{"shadeId": 3,"type": .*,"remoteAddress": .*,"name": .*, "direction": .*, "position": .*, "target": .*, "mypos": .*, "myTiltPos": .*, "tiltType": .*, "tiltDirection": .*, "tiltTarget": .*, "tiltPosition": .*, "flipCommands": .*, "flipPosition": .*, "flags": .*, "sunSensor": .*, "light": .*, "sortOrder": 2} {}
FUUID 651e6b66-f33f-05ec-2a86-6a3d4b0899d34502
NAME SomFy_RTS_02_notify_3
NOTIFYDEV SomFy_RTS_02
NR 60
NTFY_ORDER 50-SomFy_RTS_02_notify_3
REGEXP SomFy_RTS_02:UNKNOWNCODE.{"shadeId":
STATE active
TYPE notify
READINGS:
2023-10-09 09:22:50 state active
2023-10-05 08:56:46 triggeredByDev SomFy_RTS_02
2023-10-05 08:56:46 triggeredByEvent UNKNOWNCODE {"shadeId":3,"type":1,"remoteAddress":970383,"name":"Mitte","direction":0,"position":0,"target":0,"mypos":-1,"myTiltPos":-1,"tiltType":2,"tiltDirection":0,"tiltTarget":0,"tiltPosition":0,"flipCommands":false,"flipPosition":false,"flags":1,"sunSensor":false,"light":false,"sortOrder":2}
Attributes:
addStateEvent 1
readLog 1
room SomFy
FileLog
Internals:
DEF ./log/SomFy_RTS_02_FileLog_1.log SomFy_RTS_02:UNKNOWNCODE.{"shadeId":3,"type":.*,"remoteAddress":.*,"name":.*,"direction":.*,"position":.*,"target":.*,"mypos":.*,"myTiltPos":.*,"tiltType":.*,"tiltDirection":.*,"tiltTarget":.*,"tiltPosition":.*,"flipCommands":.*,"flipPosition":.*,"flags":.*,"sunSensor":.*,"light":.*,"sortOrder":.*}
FD 7
FUUID 65239bc1-f33f-05ec-4925-dd66193ff7ba4340
NAME SomFy_RTS_02_FileLog_1
NOTIFYDEV SomFy_RTS_02
NR 67
NTFY_ORDER 50-SomFy_RTS_02_FileLog_1
REGEXP SomFy_RTS_02:UNKNOWNCODE.{"shadeId":3,"type":.*,"remoteAddress":.*,"name":.*,"direction":.*,"position":.*,"target":.*,"mypos":.*,"myTiltPos":.*,"tiltType":.*,"tiltDirection":.*,"tiltTarget":.*,"tiltPosition":.*,"flipCommands":.*,"flipPosition":.*,"flags":.*,"sunSensor":.*,"light":.*,"sortOrder":.*}
STATE active
TYPE FileLog
currentlogfile ./log/SomFy_RTS_02_FileLog_1.log
logfile ./log/SomFy_RTS_02_FileLog_1.log
READINGS:
2023-10-09 09:18:53 linesInTheFile 1626
Attributes:
room SomFy
2023-10-09_09:17:38 SomFy_RTS_02 UNKNOWNCODE {"shadeId":3,"remoteAddress":374799,"cmd":"My","source":"internal","rcode":248,"sourceAddress":374799}
2023-10-09_09:17:38 SomFy_RTS_02 UNKNOWNCODE {"shadeId":3,"type":1,"remoteAddress":374799,"name":"Markise WZ-rechts","direction":0,"position":7,"target":7,"mypos":-1,"myTiltPos":-1,"tiltType":2,"tiltDirection":0,"tiltTarget":0,"tiltPosition":0,"flipCommands":false,"flipPosition":false,"flags":1,"sunSensor":false,"light":false,"sortOrder":2}
2023-10-09_09:18:51 SomFy_RTS_02 UNKNOWNCODE {"shadeId":3,"type":1,"remoteAddress":374799,"name":"Markise WZ-rechts","direction":-1,"position":6,"target":0,"mypos":-1,"myTiltPos":-1,"tiltType":2,"tiltDirection":0,"tiltTarget":0,"tiltPosition":0,"flipCommands":false,"flipPosition":false,"flags":1,"sunSensor":false,"light":false,"sortOrder":2}
2023-10-09_09:18:51 SomFy_RTS_02 UNKNOWNCODE {"shadeId":3,"type":1,"remoteAddress":374799,"name":"Markise WZ-rechts","direction":-1,"position":5,"target":0,"mypos":-1,"myTiltPos":-1,"tiltType":2,"tiltDirection":0,"tiltTarget":0,"tiltPosition":0,"flipCommands":false,"flipPosition":false,"flags":1,"sunSensor":false,"light":false,"sortOrder":2}
2023-10-09_09:18:51 SomFy_RTS_02 UNKNOWNCODE {"shadeId":3,"type":1,"remoteAddress":374799,"name":"Markise WZ-rechts","direction":-1,"position":4,"target":0,"mypos":-1,"myTiltPos":-1,"tiltType":2,"tiltDirection":0,"tiltTarget":0,"tiltPosition":0,"flipCommands":false,"flipPosition":false,"flags":1,"sunSensor":false,"light":false,"sortOrder":2}
2023-10-09_09:18:52 SomFy_RTS_02 UNKNOWNCODE {"shadeId":3,"type":1,"remoteAddress":374799,"name":"Markise WZ-rechts","direction":-1,"position":3,"target":0,"mypos":-1,"myTiltPos":-1,"tiltType":2,"tiltDirection":0,"tiltTarget":0,"tiltPosition":0,"flipCommands":false,"flipPosition":false,"flags":1,"sunSensor":false,"light":false,"sortOrder":2}
2023-10-09_09:18:52 SomFy_RTS_02 UNKNOWNCODE {"shadeId":3,"type":1,"remoteAddress":374799,"name":"Markise WZ-rechts","direction":-1,"position":2,"target":0,"mypos":-1,"myTiltPos":-1,"tiltType":2,"tiltDirection":0,"tiltTarget":0,"tiltPosition":0,"flipCommands":false,"flipPosition":false,"flags":1,"sunSensor":false,"light":false,"sortOrder":2}
2023-10-09_09:18:52 SomFy_RTS_02 UNKNOWNCODE {"shadeId":3,"type":1,"remoteAddress":374799,"name":"Markise WZ-rechts","direction":-1,"position":1,"target":0,"mypos":-1,"myTiltPos":-1,"tiltType":2,"tiltDirection":0,"tiltTarget":0,"tiltPosition":0,"flipCommands":false,"flipPosition":false,"flags":1,"sunSensor":false,"light":false,"sortOrder":2}
2023-10-09_09:18:53 SomFy_RTS_02 UNKNOWNCODE {"shadeId":3,"type":1,"remoteAddress":374799,"name":"Markise WZ-rechts","direction":-1,"position":0,"target":0,"mypos":-1,"myTiltPos":-1,"tiltType":2,"tiltDirection":0,"tiltTarget":0,"tiltPosition":0,"flipCommands":false,"flipPosition":false,"flags":1,"sunSensor":false,"light":false,"sortOrder":2}
2023-10-09_09:18:53 SomFy_RTS_02 UNKNOWNCODE {"shadeId":3,"type":1,"remoteAddress":374799,"name":"Markise WZ-rechts","direction":0,"position":0,"target":0,"mypos":-1,"myTiltPos":-1,"tiltType":2,"tiltDirection":0,"tiltTarget":0,"tiltPosition":0,"flipCommands":false,"flipPosition":false,"flags":1,"sunSensor":false,"light":false,"sortOrder":2}
Zwar keine direkte Antwort auf die Frage aber vielleicht hilft das: Ich mache das mit MQTT. ESP-SOMFY-RTS mit einem Garagentor (eine Taste Stat/Stop), einer Markise, und einem Rollo. Zusätzlich schicke ich noch Befehle von einem ShellyI4 über Websocket an ESP-SOMFY-RTS. Wenn ein shade in Bewegung ist, kommt seit ESP-Somfy Version 2.19 pro % Bewegung eine MQTT-message für die Position und damit ein entsprechendes Reading in FHEM. Das können bei kurzen Rollos schon 10 und mehr Messages pro Sekunde sein und wenn mehrere Rollos gleichzeitig unterwegs sind es entsprechend mehr. FHEM mit MQTT2 auf einem Raspi3 kommt da schon an seine Grenzen (kurzzeitig 100% CPU Last). Aber im Prinzip funktioniert das gut so. Hier meine Konfiguration. Eine Aufteilung auf ein Device pro shade wäre sicher eleganter, aber für meine Zwecke reicht das so. LG
defmod ESP_Somfy_RTS MQTT2_DEVICE client_0000f4fcd21b5ae0
attr ESP_Somfy_RTS alexaName Markise;; Markise-gross;; grosse-Markise
attr ESP_Somfy_RTS autocreate 1
attr ESP_Somfy_RTS cmdIcon Markise_ausfahren:control_centr_arrow_down Markise_einfahren:control_centr_arrow_up Markise_stop:control_x my:fts_shutter_50
attr ESP_Somfy_RTS devStateIcon online:10px-kreis-gruen offline:10px-kreis-rot 0:fts_sunblind_0 100:fts_sunblind_100 9\d.*:fts_sunblind_90 8\d.*:fts_sunblind_80 7\d.*:fts_sunblind_70 6\d.*:fts_sunblind_60 5\d.*:fts_sunblind_50 4\d.*:fts_sunblind_60 3\d.*:fts_sunblind_30 2\d.*:fts_sunblind_20 1\d.*:fts_sunblind_10 0\d.*:fts_sunblind_0 set_.*:fts_sunblind_updown
attr ESP_Somfy_RTS genericDeviceType blind
attr ESP_Somfy_RTS icon fts_sunblind
attr ESP_Somfy_RTS readingList client_0000f4fcd21b5ae0:Somfy/status:.* status\
client_0000f4fcd21b5ae0:Somfy/shades/1/shadeId:.* shades_1_shadeId\
client_0000f4fcd21b5ae0:Somfy/shades/1/name:.* shades_1_name\
client_0000f4fcd21b5ae0:Somfy/shades/1/remoteAddress:.* shades_1_remoteAddress\
client_0000f4fcd21b5ae0:Somfy/shades/1/shadeType:.* shades_1_shadeType\
client_0000f4fcd21b5ae0:Somfy/shades/1/tiltType:.* shades_1_tiltType\
client_0000f4fcd21b5ae0:Somfy/shades/1/flipCommands:.* shades_1_flipCommands\
client_0000f4fcd21b5ae0:Somfy/shades/1/flipPosition:.* shades_1_flipPosition\
client_0000f4fcd21b5ae0:Somfy/shades/1/position:.* shades_1_position\
client_0000f4fcd21b5ae0:Somfy/shades/1/direction:.* shades_1_direction\
client_0000f4fcd21b5ae0:Somfy/shades/1/target:.* shades_1_target\
client_0000f4fcd21b5ae0:Somfy/shades/1/lastRollingCode:.* shades_1_lastRollingCode\
client_0000f4fcd21b5ae0:Somfy/shades/1/mypos:.* shades_1_mypos\
client_0000f4fcd21b5ae0:Somfy/shades/1/myTiltPos:.* shades_1_myTiltPos\
client_0000f4fcd21b5ae0:Somfy/shades/1/sunSensor:.* shades_1_sunSensor\
client_0000f4fcd21b5ae0:Somfy/shades/2/shadeId:.* shades_2_shadeId\
client_0000f4fcd21b5ae0:Somfy/shades/2/name:.* shades_2_name\
client_0000f4fcd21b5ae0:Somfy/shades/2/remoteAddress:.* shades_2_remoteAddress\
client_0000f4fcd21b5ae0:Somfy/shades/2/shadeType:.* shades_2_shadeType\
client_0000f4fcd21b5ae0:Somfy/shades/2/tiltType:.* shades_2_tiltType\
client_0000f4fcd21b5ae0:Somfy/shades/2/flipCommands:.* shades_2_flipCommands\
client_0000f4fcd21b5ae0:Somfy/shades/2/flipPosition:.* shades_2_flipPosition\
client_0000f4fcd21b5ae0:Somfy/shades/2/position:.* shades_2_position\
client_0000f4fcd21b5ae0:Somfy/shades/2/direction:.* shades_2_direction\
client_0000f4fcd21b5ae0:Somfy/shades/2/target:.* shades_2_target\
client_0000f4fcd21b5ae0:Somfy/shades/2/lastRollingCode:.* shades_2_lastRollingCode\
client_0000f4fcd21b5ae0:Somfy/shades/2/mypos:.* shades_2_mypos\
client_0000f4fcd21b5ae0:Somfy/shades/2/myTiltPos:.* shades_2_myTiltPos\
client_0000f4fcd21b5ae0:Somfy/shades/2/sunSensor:.* shades_2_sunSensor\
client_0000f4fcd21b5ae0:Somfy/shades/3/shadeId:.* shades_3_shadeId\
client_0000f4fcd21b5ae0:Somfy/shades/3/name:.* shades_3_name\
client_0000f4fcd21b5ae0:Somfy/shades/3/remoteAddress:.* shades_3_remoteAddress\
client_0000f4fcd21b5ae0:Somfy/shades/3/shadeType:.* shades_3_shadeType\
client_0000f4fcd21b5ae0:Somfy/shades/3/tiltType:.* shades_3_tiltType\
client_0000f4fcd21b5ae0:Somfy/shades/3/flipCommands:.* shades_3_flipCommands\
client_0000f4fcd21b5ae0:Somfy/shades/3/flipPosition:.* shades_3_flipPosition\
client_0000f4fcd21b5ae0:Somfy/shades/3/position:.* shades_3_position\
client_0000f4fcd21b5ae0:Somfy/shades/3/direction:.* shades_3_direction\
client_0000f4fcd21b5ae0:Somfy/shades/3/target:.* shades_3_target\
client_0000f4fcd21b5ae0:Somfy/shades/3/lastRollingCode:.* shades_3_lastRollingCode\
client_0000f4fcd21b5ae0:Somfy/shades/3/mypos:.* shades_3_mypos\
client_0000f4fcd21b5ae0:Somfy/shades/3/myTiltPos:.* shades_3_myTiltPos\
client_0000f4fcd21b5ae0:Somfy/shades/3/sunSensor:.* shades_3_sunSensor\
client_0000f4fcd21b5ae0:Somfy/shades:.* { json2nameValue($EVENT, 'shades_', $JSONMAP) }\
client_0000f4fcd21b5ae0:Somfy/groups:.* groups\
client_0000f4fcd21b5ae0:Somfy/ipAddress:.* ipAddress\
client_0000f4fcd21b5ae0:Somfy/host:.* host\
client_0000f4fcd21b5ae0:Somfy/firmware:.* firmware\
client_0000f4fcd21b5ae0:Somfy/serverId:.* serverId\
client_0000f4fcd21b5ae0:Somfy/mac:.* mac
attr ESP_Somfy_RTS room Alexa,Garage,MQTT2_DEVICE,SOMFY
attr ESP_Somfy_RTS setList pct:slider,0,1,100 Somfy/shades/1/target/set\
Markise_target Somfy/shades/1/target/set\
Markise_my:noArg Somfy/shades/1/target/set 66\
Markise_einfahren:noArg Somfy/shades/1/direction/set -1\
Markise_ausfahren:noArg Somfy/shades/1/direction/set 1\
Markise_stop:noArg Somfy/shades/1/direction/set 0\
Garage:noArg Somfy/shades/3/direction/set 0ct
attr ESP_Somfy_RTS stateFormat Markise: shades_1_position %\
<br>\
RolloDG: shades_2_position %\
<br>\
Garage: shades_3_position %\
<br>\
<a href="http://ipAddress" target="_blank">ipAddress</a>\
status
attr ESP_Somfy_RTS webCmd Markise_ausfahren:Markise_stop:Markise_einfahren:::Garage
setstate ESP_Somfy_RTS Markise: 0 %\
<br>\
RolloDG: 0 %\
<br>\
Garage: 100 %\
<br>\
<a href="http://10.152.52.113" target="_blank">10.152.52.113</a>\
online
@buec65: Bitte verwende code-Tags um sowas einigermaßen lesbar darzustellen.
Eigentlich musst Du doch nur Dein notify, das aktuell noch gar nix tut, um den passenden Ausführungsteil ergänzen. Im einfachsten Fall sollte ein json2reading($EVTPART1) schon ausreichen, um aus den json Daten readings mit Inhalten zu erzeugen.
defmod SomFy_RTS_02_notify_99 notify SomFy_RTS_02:UNKNOWNCODE:{.*} {json2reading("SomFy_RTS_02",$EVTPART1)}
@Tremichl
Bei mir funktioniert es mit Mqtt2 leider nicht zuverlässig.
@betateilchen
Werde ich versuchen, vielen Dank.
Ideal wäre natürlich ein eigenes Modul aber von Perl habe ich keine Ahnung und Websocket-Module habe ich auch nicht wirklich gefunden.
Es ist doch egal, woher die Daten kommen, es geht doch im um deren Weiterverarbeitung.
@betateilchen
danke für den Tip das funktioniert und es werden Readings angelegt, leider landet da immer der letzte Wert ich bräuchte aber für jede shadeId":1 - 6 jeweils die zugehörigen Werte
Internals:
DEF SomFy_RTS_02:UNKNOWNCODE.{.*} {json2reading("SomFy_RTS_02_sh_1",$EVTPART1)}
FUUID 6530dbf2-f33f-05ec-1ce4-a10463b9b6b5283e
NAME SomFy_RTS_02_notify_99
NOTIFYDEV SomFy_RTS_02
NR 72
NTFY_ORDER 50-SomFy_RTS_02_notify_99
REGEXP SomFy_RTS_02:UNKNOWNCODE.{.*}
STATE 2023-10-19 13:28:29
TYPE notify
READINGS:
2023-10-19 14:40:41 state active
2023-10-19 13:28:29 triggeredByDev SomFy_RTS_02
2023-10-19 13:28:29 triggeredByEvent UNKNOWNCODE {"shadeId":2,"remoteAddress":374798,"cmd":"Up","source":"internal","rcode":160,"sourceAddress":374798}
Attributes:
room SomFy
2023.10.19 08:46:17 5: UBUS (SomFy_RTS_02) - received: {"shadeId":4,"remoteAddress":374800,"cmd":"Up","source":"internal","rcode":175,"sourceAddress":374800}
2023.10.19 08:46:17 5: SomFy_RTS_02: dispatch {"shadeId":4,"remoteAddress":374800,"cmd":"Up","source":"internal","rcode":175,"sourceAddress":374800}
2023.10.19 08:46:17 3: SomFy_RTS_02: Unknown code {"shadeId":4,"remoteAddress":374800,"cmd":"Up","source":"internal","rcode":175,"sourceAddress":374800}, help me!
2023.10.19 08:47:27 5: UBUS (SomFy_RTS_02) - received: {"shadeId":1,"remoteAddress":374797,"cmd":"Up","source":"internal","rcode":208,"sourceAddress":374797}
2023.10.19 08:47:27 5: SomFy_RTS_02: dispatch {"shadeId":1,"remoteAddress":374797,"cmd":"Up","source":"internal","rcode":208,"sourceAddress":374797}
2023.10.19 08:47:27 3: SomFy_RTS_02: Unknown code {"shadeId":1,"remoteAddress":374797,"cmd":"Up","source":"internal","rcode":208,"sourceAddress":374797}, help me!