publishSet automatisch ausführen

Begonnen von TWART016, 27 Juni 2020, 03:00:24

Vorheriges Thema - Nächstes Thema

TWART016

Hallo,

ich habe ein MQTT_Device, wo ich die Readings per Tablet UI setzte. Nun möchte ich, wenn sich das Reading status_set ändert, automatisch ein PublishSet von status_set gemacht wird. Wie setzte ich das am besten um?

Wenn ich über MQTT manuell schalte, wird richtig geschalten:

shellies/shellyrgbw2-5A3992/color/0/set
{"turn":"on","red":255,"green":255,"blue":255,"white":255,"gain":0,"effect":0}


Internals:
   FUUID      5ccc89a1-f33f-50ef-dba7-fdcd9d9ed78fea46
   FVERSION   10_MQTT_DEVICE.pm:0.173620/2018-09-17
   IODev      Mosquitto
   NAME       Shelly_Wohnzimmer_test
   NR         938
   STATE      on
   TYPE       MQTT_DEVICE
   OLDREADINGS:
   READINGS:
     2020-06-27 02:53:40   blue            255
     2020-06-27 02:47:13   effect          0
     2020-06-27 02:47:13   gain            0
     2020-06-27 02:53:40   green           255
     2020-06-27 02:47:13   ison            1
     2020-06-27 02:47:13   mode            color
     2020-06-27 02:47:13   overpower       0
     2020-06-27 02:47:13   power           41.05
     2020-06-27 02:53:40   red             255
     2020-06-27 02:53:40   rgb             FFFFFF
     2020-06-27 02:53:40   state           on
     2020-06-27 02:53:40   status_get      {"ison":true,"mode":"color","red":255,"green":255,"blue":255,"white":255,"gain":0,"effect":0,"power":41.05,"overpower":false}
     2020-06-27 02:53:40   status_set      {"turn":"on","red":255,"green":255,"blue":255,"white":255,"gain":0,"effect":0}
     2020-06-27 02:53:40   test            {"turn":"on","red":255,"green":255,"blue":255,"white":255,"gain":0,"effect":0}
     2020-06-27 02:53:40   transmission-state incoming publish received
     2020-06-27 02:46:51   turn            on
     2020-06-27 02:47:13   white           255
   message_ids:
   publishSets:
     :
       topic      shellies/shellyrgbw2-5A3992/color/0/command
       values:
         on
         off
     status_set:
       topic      shellies/shellyrgbw2-5A3992/color/0/set
       values:
     test:
       topic      shellies/shellyrgbw2-5A3992/color/0/set
       values:
   sets:
     off       
     on         
     status_set
     test       
   subscribe:
     shellies/shellyrgbw2-5A3992/color/0
     shellies/shellyrgbw2-5A3992/color/0/status
   subscribeExpr:
     ^shellies\/shellyrgbw2-5A3992\/color\/0$
     ^shellies\/shellyrgbw2-5A3992\/color\/0\/status$
   subscribeQos:
     shellies/shellyrgbw2-5A3992/color/0 0
     shellies/shellyrgbw2-5A3992/color/0/status 0
   subscribeReadings:
     shellies/shellyrgbw2-5A3992/color/0:
       cmd       
       name       state
     shellies/shellyrgbw2-5A3992/color/0/status:
       cmd       
       name       status_get
Attributes:
   IODev      Mosquitto
   event-on-change-reading .*
   publishSet on off shellies/shellyrgbw2-5A3992/color/0/command
   publishSet_status_set shellies/shellyrgbw2-5A3992/color/0/set
   publishSet_test shellies/shellyrgbw2-5A3992/color/0/set
   room       10_Wohnzimmer
   subscribeReading_state shellies/shellyrgbw2-5A3992/color/0
   subscribeReading_status_get shellies/shellyrgbw2-5A3992/color/0/status
   userReadings red {hex(substr(ReadingsVal($name,"rgb",0),0,2))},
green {hex(substr(ReadingsVal($name,"rgb",0),2,2))},
blue {hex(substr(ReadingsVal($name,"rgb",0),4,2))},
status_set {'{"turn":"' .ReadingsVal($name,"state",0) .'","red":' .ReadingsVal($name,"red",0) .',"green":' .ReadingsVal($name,"green",0) .',"blue":' .ReadingsVal($name,"blue",0) .',"white":' .ReadingsVal($name,"white",0) .',"gain":' .ReadingsVal($name,"gain",0) .',"effect":0}' },
test {'{"turn":"' .ReadingsVal($name,"state",0) .'","red":' .ReadingsVal($name,"red",0) .',"green":' .ReadingsVal($name,"green",0) .',"blue":' .ReadingsVal($name,"blue",0) .',"white":' .ReadingsVal($name,"white",0) .',"gain":' .ReadingsVal($name,"gain",0) .',"effect":0}' },
rgb {
my $red = ReadingsVal($name,"red","");
my $green = ReadingsVal($name,"green","");
my $blue = ReadingsVal($name,"blue","");
Color::rgb2hex( $red,$green,$blue );
},
   userattr   subscribeReading_state publishSet_test publishSet_status_set