AskSin++ Library

Begonnen von papa, 08 September 2016, 11:11:25

Vorheriges Thema - Nächstes Thema

McShire

Hallo papa,
ich denke, diese Version ist jetzt Dank Deiner Hilfe gebrauchsfähig.
Es können jetzt jeder der beiden Ausgänge (Aktoren) für sich remote (FHEM) on oder off gesetzt werden,
oder lokal mit Taster oder mit Schalter getoggled werden.
Genau das, was ich gesucht habe, kann in der bestehenden Installation als Ausschalter, Wechselschalter oder Kreuzschalter
hinter den vorhandenen Schaltern oder Tastern eingesetzt werden. Zur Stromversorgung gibt es kleine AC230V / DC3,3V
Converter.
Ich habe hier sehr viel dazu gelernt. Nachdem ich mir in Button.h die Klasse InternalButton und weiter unten die Methode
shortPress () angesehen habe, erübrigt sich die Frage mit dem Programmdurchlauf.

Hier der jetzige Code


//- -----------------------------------------------------------------------------------------------------------------------
// AskSin++  "HM-LC-Sw2-FM-WS-locSwitch-FHEM-v1.ino"
// 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
// 2020-11-30 McShire modification for use of a switch instead of a button for local change of the actor-relay
//            connect switch to pin 9
// 2020-12-01 papa replace simulation of btn1 on pin 7 and connection pin 7 to pin 14 by a new methode shortPress()
//            in class InternalButton
//- -----------------------------------------------------------------------------------------------------------------------

// define this to read the device id, serial and device type from bootloader section
// #define USE_OTA_BOOTLOADER

#define EI_NOTEXTERNAL
#include <EnableInterrupt.h>
#include <AskSinPP.h>
#include <LowPower.h>

#include <Switch.h>

// we use a Pro Mini
// Arduino pin for the LED
// D4 == PIN 4 on Pro Mini
#define LED_PIN 4
// Arduino pin for the config button
// B0 == PIN 8 on Pro Mini
#define CONFIG_BUTTON_PIN 8

//set to 0x01 if the RELAY should be switched on LOW level
#define LOW_ACTIVE 0x00
#define RELAY1_PIN 5    // modified from A3, on my Experim.board LED2, to see relay state
#define RELAY2_PIN 6    // modified from A2

#define BUTTON1_PIN 14
#define BUTTON2_PIN 15

#define SWITCH1_PIN 9  // inserted McShire
#define SWITCH2_PIN 7  // Pin 9 und Pin 7 connect to switch, other switch pole to ground

// number of available peers per channel
#define PEERS_PER_CHANNEL 8

// all library classes are placed in the namespace 'as'
using namespace as;

// define all device properties
const struct DeviceInfo PROGMEM devinfo = {
  {0x12, 0x09, 0x01},     // Device ID
  "JPLCSw2001",           // Device Serial
  {0x00, 0x09},           // Device Model
  0x24,                   // Firmware Version
  as::DeviceType::Switch, // Device Type
  {0x01, 0x00}            // Info Bytes
};

/**
   Configure the used hardware
*/
typedef AvrSPI<10, 11, 12, 13> RadioSPI;
typedef AskSin<StatusLed<LED_PIN>, NoBattery, Radio<RadioSPI, 2> > Hal;

// setup the device with channel type and number of channels
typedef MultiChannelDevice<Hal, SwitchChannel<Hal, PEERS_PER_CHANNEL, List0>, 2> SwitchType;

// inserted by McShire
boolean localon1 = false;   // state of the Switch1, true = on, false = off
boolean localon2 = false;   // state of the Switch2, true = on, false = off


Hal hal;
SwitchType sdev(devinfo, 0x20);
ConfigButton<SwitchType> cfgBtn(sdev);
InternalButton<SwitchType> btn1(sdev, 1);
InternalButton<SwitchType> btn2(sdev, 2);

void initPeerings (bool first) {
  // create internal peerings - CCU2 needs this
  if ( first == true ) {
    HMID devid;
    sdev.getDeviceID(devid);
    for ( uint8_t i = 1; i <= sdev.channels(); ++i ) {
      Peer ipeer(devid, i);
      sdev.channel(i).peer(ipeer);
    }
  }
}

void setup () {
  DINIT(57600, ASKSIN_PLUS_PLUS_IDENTIFIER);
  bool first = sdev.init(hal);
  sdev.channel(1).init(RELAY1_PIN, LOW_ACTIVE);
  sdev.channel(2).init(RELAY2_PIN, LOW_ACTIVE);

  buttonISR(cfgBtn, CONFIG_BUTTON_PIN);
  buttonISR(btn1, BUTTON1_PIN);
  buttonISR(btn2, BUTTON2_PIN);

  pinMode(SWITCH1_PIN, INPUT_PULLUP); // inserted by McShire
  pinMode(SWITCH2_PIN, INPUT_PULLUP); // inserted by McShire

  sdev.channels(2);
  initPeerings(first);
  sdev.initDone();
}

void loop() {
  bool worked = hal.runready();


// Version v1 Modification created by papa
if( localon1 != digitalRead(SWITCH1_PIN) ) {
  delay(50);                                   //wait because of possible switch bouncing
  localon1 = !localon1;
  btn1.shortPress();
}
if( localon2 != digitalRead(SWITCH2_PIN) ) {
  delay(50);                                   //wait because of possible switch bouncing
  localon2 = !localon2;
  btn2.shortPress();
}

  bool poll = sdev.pollRadio();
  if ( worked == false && poll == false ) {
    hal.activity.savePower<Idle<> >(hal);
  }
}


Viele Grüße
Werner

papa

Schön das es so gut funktioniert. War ja dann auch nicht wirklich kompliziert.
BananaPi + CUL868 + CUL433 + HM-UART + 1Wire

McShire

Hallo papa,
für mich war es schon erstmal kompliziert. Du musst das immer aus
der Brille eines Unkundigen betrachten. Aber so langsam komme ich dahinter.
Bis zum nächsten Projekt.
Ich wünsche ein schönes Wochenende
Werner

McShire

Hallo zusammen,
gibt es für den Asksin-Analyzer auch einen Sketch mit dem 433MHz Protokolle angezeigt werden?
Viele Grüße
Werner

Beetle2003

Guten Morgen,

ich suche nach einem Sketch, bei dem die Ausgänge eine Blinkfrequenz haben und diese, sofern möglich noch von aussen beeinflusst werden kann.

Derzeit nutze ich hierfür ein HM-LC-SW2-SM welcher an den Ausgängen LEDs hat und über MSwitch lasse ich diese blinken. Das führt zu einem Overload an den HMLANs und CUL.

Somit eine schlechte Idee. Wer kann mir einen besseren Tipp geben?

Danke

McShire

Hallo,
noch an einem Blinker interessiert? ich hätte da vielleicht etwas.
Den folgenden Sketch auf eine AskSinPP-Hardware https://asksinpp.de/Grundlagen/01_hardware.html#microcontroller flashen.
Mit autocreate und config-button in FHEM ein device anlegen.
Mit Button1 (Toggle) oder Switch1 (E/A-Schalter) oder in FHEM wird der Blinker ein- bzw. ausgeschaltet (RELAY1).
Die Blinkfrequenz kann mit Button2 (Toggle) oder Switch2 (E/A-Schalter) oder in FHEM eingestellt werden.
Die Einschaltdauer von RELAY2 (mit max begrenzt) stellt die Periodendauer für die Blinkfrequenz ein.
Die LEDs oder ein Relay oder Transistor werden an RELAY3 angeschlossen.
Die Anschlussbelegungen für Taster bzw. Schalter und den Blinkerausgang gehen aus dem Code hervor und können dort verändert werden.


//- -----------------------------------------------------------------------------------------------------------------------
// AskSin++  "HM-LC-Sw2-FM-WS-Blink-v1.ino"
// 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
// 2020-11-30 McShire modification for use of a switch instead of a button for local change of the actor-relay
//            connect switch to pin 9
// 2020-12-01 papa replace simulation of btn1 on pin 7 and connection pin 7 to pin 14 by a new methode shortPress()
//            in class InternalButton
//- -----------------------------------------------------------------------------------------------------------------------

// define this to read the device id, serial and device type from bootloader section
// #define USE_OTA_BOOTLOADER

#define EI_NOTEXTERNAL
#include <EnableInterrupt.h>
#include <AskSinPP.h>
#include <LowPower.h>

#include <Switch.h>

// we use a Pro Mini
// Arduino pin for the LED
// D4 == PIN 4 on Pro Mini
#define LED_PIN 4
// Arduino pin for the config button
// B0 == PIN 8 on Pro Mini
#define CONFIG_BUTTON_PIN 8

//set to 0x01 if the RELAY should be switched on LOW level
#define LOW_ACTIVE 0x00
#define RELAY1_PIN 5    // modified from A3 in original
#define RELAY2_PIN 6    // modified from A2

#define BUTTON1_PIN 14  //A0, connect to local button (Toggle Betrieb RELAY1)
#define BUTTON2_PIN 15  //A1, connect to local button (Toggle Betrieb RELAY2)

#define SWITCH1_PIN 9  // inserted McShire, connect to local SWITCH1
#define SWITCH2_PIN 7  // connect to local SWITCH2, switches against ground
#define RELAY3_PIN 17   // A3, blink signal output

// number of available peers per channel
#define PEERS_PER_CHANNEL 8

// all library classes are placed in the namespace 'as'
using namespace as;

// define all device properties
const struct DeviceInfo PROGMEM devinfo = {
  {0x12, 0x09, 0x01},     // Device ID
  "JPLCSw2001",           // Device Serial
  {0x00, 0x09},           // Device Model
  0x24,                   // Firmware Version
  as::DeviceType::Switch, // Device Type
  {0x01, 0x00}            // Info Bytes
};

/**
   Configure the used hardware
*/
typedef AvrSPI<10, 11, 12, 13> RadioSPI;
typedef AskSin<StatusLed<LED_PIN>, NoBattery, Radio<RadioSPI, 2> > Hal;

// setup the device with channel type and number of channels
typedef MultiChannelDevice<Hal, SwitchChannel<Hal, PEERS_PER_CHANNEL, List0>, 2> SwitchType;

// inserted by McShire
boolean localon1 = false;   // prior state of Switch1, true = on, false = off
boolean localon2 = false;   // prior state of Switch2, true = on, false = off
int peri_max = 10;         // predefined number of loops for blink/no blink time
int peri_count = 0;         // counter for actual number of loops
int peri_set = 0;           // Counter for setting peri_max using SWITCH2
int peri_set_max = 5000; // Limit for peri_max
boolean blink = LOW;
boolean rel_old = LOW;

Hal hal;
SwitchType sdev(devinfo, 0x20);
ConfigButton<SwitchType> cfgBtn(sdev);
InternalButton<SwitchType> btn1(sdev, 1);
InternalButton<SwitchType> btn2(sdev, 2);

void initPeerings (bool first) {
  // create internal peerings - CCU2 needs this
  if ( first == true ) {
    HMID devid;
    sdev.getDeviceID(devid);
    for ( uint8_t i = 1; i <= sdev.channels(); ++i ) {
      Peer ipeer(devid, i);
      sdev.channel(i).peer(ipeer);
    }
  }
}

void setup () {
  DINIT(57600, ASKSIN_PLUS_PLUS_IDENTIFIER);
  bool first = sdev.init(hal);
  sdev.channel(1).init(RELAY1_PIN, LOW_ACTIVE);
  sdev.channel(2).init(RELAY2_PIN, LOW_ACTIVE);

  buttonISR(cfgBtn, CONFIG_BUTTON_PIN);
  buttonISR(btn1, BUTTON1_PIN);
  buttonISR(btn2, BUTTON2_PIN);

  pinMode(SWITCH1_PIN, INPUT_PULLUP); // inserted by McShire
  pinMode(SWITCH2_PIN, INPUT_PULLUP); // inserted by McShire
  pinMode(RELAY3_PIN, OUTPUT);

  digitalWrite(RELAY1_PIN,LOW);
  digitalWrite(RELAY2_PIN,LOW);
  digitalWrite(RELAY3_PIN,LOW);

  sdev.channels(2);
  initPeerings(first);
  sdev.initDone();
}

void loop() {
  bool worked = hal.runready();


// Version v1 Modification created by papa
if( localon1 != digitalRead(SWITCH1_PIN) ) {   //state of switch1 has changed?
  delay(50);                                   //wait because of possible switch bouncing
  localon1 = !localon1;                        //save new state of switch1
  btn1.shortPress();                           //generate virtual press Button (Toggle Relay1
                                               //and send Msg to FHEM)
}
if( localon2 != digitalRead(SWITCH2_PIN) ) {   //state of switch2 has changed?
  delay(50);                                   //wait because of possible switch bouncing
  localon2 = !localon2;                        //save new state of switch2
  btn2.shortPress();                           //generate virtual press Button (Toggle Relay2
                                               //and send Msg to FHEM)
}

Serial.print(digitalRead(RELAY3_PIN));
Serial.print("   "); Serial.print(peri_count); Serial.print("   ");
Serial.println(peri_max);
if( digitalRead(RELAY1_PIN) == HIGH ) { //Blink is set on
  peri_count++;
  if( peri_count >= peri_max ) {
    blink = !blink;
    digitalWrite(RELAY3_PIN,blink);
    peri_count = 0;
  }
}
else {
  blink = LOW;
  digitalWrite(RELAY3_PIN,blink) ;
}

if( digitalRead(RELAY2_PIN) == HIGH) {  // set new duration of blink / no blink time
  if (rel_old == LOW) peri_set = 0;
  if (peri_set <= peri_set_max) {
    peri_set++;
  }
}
else {
  peri_max = peri_set;
}
rel_old = digitalRead(RELAY2_PIN);

  bool poll = sdev.pollRadio();
  if ( worked == false && poll == false ) {
    hal.activity.savePower<Idle<> >(hal);
  }
}


Viel Spass und Erfolg und frohe Weihnachten.
Werner

Beetle2003

Hallo Werner,

vielen Dank für das Beispiel.
Ich werde dieses in den nächsten Tagen probieren und Dir eine Rückmeldung geben.

Danke erst einmal und einen schönen 2. Weihnachtstag.

Bleib gesund.

Gruss

Ralf

McShire

Hallo Ralf,
die Blinkfrequenz lässt sich besser steuern, wenn Du unten die Zeile
  peri_max = peri_set;
ersetzt durch
  peri_max = peri_set/5;
ersetzt.
Viele Grüße
Werner

McShire

Hallo Ralf,
Update auf bessere Anfangsbedingungen

//- -----------------------------------------------------------------------------------------------------------------------
// AskSin++  "HM-LC-Sw2-FM-WS-Blink-v1.ino"
// 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
// 2020-11-30 McShire modification for use of a switch instead of a button for local change of the actor-relay
//            connect switch to pin 9
// 2020-12-01 papa replace simulation of btn1 on pin 7 and connection pin 7 to pin 14 by a new methode shortPress()
//            in class InternalButton
// 2020-12-27 McShire new funktion blink output at RELAY3 output, on/off controlled bei RELAY1 state,
//            blink frequency set by on-time RELAY2
//- -----------------------------------------------------------------------------------------------------------------------

// define this to read the device id, serial and device type from bootloader section
// #define USE_OTA_BOOTLOADER

#define EI_NOTEXTERNAL
#include <EnableInterrupt.h>
#include <AskSinPP.h>
#include <LowPower.h>

#include <Switch.h>

// we use a Pro Mini
// Arduino pin for the LED
// D4 == PIN 4 on Pro Mini
#define LED_PIN 4
// Arduino pin for the config button
// B0 == PIN 8 on Pro Mini
#define CONFIG_BUTTON_PIN 8

//set to 0x01 if the RELAY should be switched on LOW level
#define LOW_ACTIVE 0x00
#define RELAY1_PIN 16    //  A2
#define RELAY2_PIN 17    //  A3

#define BUTTON1_PIN 14  //A0, connect to local button (Toggle Betrieb RELAY1)
#define BUTTON2_PIN 15  //A1, connect to local button (Toggle Betrieb RELAY2)

#define SWITCH1_PIN 9  // inserted McShire, connect to local SWITCH1
#define SWITCH2_PIN 7  // connect to local SWITCH2, switches against ground
#define RELAY3_PIN 6   // blink signal output

// number of available peers per channel
#define PEERS_PER_CHANNEL 8

// all library classes are placed in the namespace 'as'
using namespace as;

// define all device properties
const struct DeviceInfo PROGMEM devinfo = {
  {0x12, 0x09, 0x01},     // Device ID
  "JPLCSw2001",           // Device Serial
  {0x00, 0x09},           // Device Model
  0x24,                   // Firmware Version
  as::DeviceType::Switch, // Device Type
  {0x01, 0x00}            // Info Bytes
};

/**
   Configure the used hardware
*/
typedef AvrSPI<10, 11, 12, 13> RadioSPI;
typedef AskSin<StatusLed<LED_PIN>, NoBattery, Radio<RadioSPI, 2> > Hal;

// setup the device with channel type and number of channels
typedef MultiChannelDevice<Hal, SwitchChannel<Hal, PEERS_PER_CHANNEL, List0>, 2> SwitchType;

// inserted by McShire
boolean localon1 = false;   // prior state of Switch1, true = on, false = off
boolean localon2 = false;   // prior state of Switch2, true = on, false = off
int peri_max = 50;         // predefined number of loops for blink/no blink time
int peri_count = 1;         // counter for actual number of loops
int peri_set = 50;           // Counter for setting peri_max using SWITCH2
int peri_set_max = 5000; // Limit for peri_max
boolean blink = LOW;
boolean rel_old = LOW;

Hal hal;
SwitchType sdev(devinfo, 0x20);
ConfigButton<SwitchType> cfgBtn(sdev);
InternalButton<SwitchType> btn1(sdev, 1);
InternalButton<SwitchType> btn2(sdev, 2);

void initPeerings (bool first) {
  // create internal peerings - CCU2 needs this
  if ( first == true ) {
    HMID devid;
    sdev.getDeviceID(devid);
    for ( uint8_t i = 1; i <= sdev.channels(); ++i ) {
      Peer ipeer(devid, i);
      sdev.channel(i).peer(ipeer);
    }
  }
}

void setup () {
  DINIT(57600, ASKSIN_PLUS_PLUS_IDENTIFIER);
  bool first = sdev.init(hal);
  sdev.channel(1).init(RELAY1_PIN, LOW_ACTIVE);
  sdev.channel(2).init(RELAY2_PIN, LOW_ACTIVE);

  buttonISR(cfgBtn, CONFIG_BUTTON_PIN);
  buttonISR(btn1, BUTTON1_PIN);
  buttonISR(btn2, BUTTON2_PIN);

  pinMode(SWITCH1_PIN, INPUT_PULLUP); // inserted by McShire
  pinMode(SWITCH2_PIN, INPUT_PULLUP); // inserted by McShire
  pinMode(RELAY3_PIN, OUTPUT);
  sdev.channels(2);
  initPeerings(first);
  sdev.initDone();

  digitalWrite(RELAY3_PIN,LOW);
  btn1.shortPress();
  btn2.shortPress();
}

void loop() {
  bool worked = hal.runready();


// Version v1 Modification created by papa
if( localon1 != digitalRead(SWITCH1_PIN) ) {   //state of switch1 has changed?
  delay(50);                                   //wait because of possible switch bouncing
  localon1 = !localon1;                        //save new state of switch1
  btn1.shortPress();                           //generate virtual press Button (Toggle Relay1
                                               //and send Msg to FHEM)
}
if( localon2 != digitalRead(SWITCH2_PIN) ) {   //state of switch2 has changed?
  delay(50);                                   //wait because of possible switch bouncing
  localon2 = !localon2;                        //save new state of switch2
  btn2.shortPress();                           //generate virtual press Button (Toggle Relay2
                                               //and send Msg to FHEM)
}

Serial.print(digitalRead(RELAY3_PIN));
Serial.print("   "); Serial.print(peri_count); Serial.print("   ");
Serial.print(peri_max); Serial.print("   "); Serial.println(peri_set);
if( digitalRead(RELAY1_PIN) == HIGH ) { //Blink is set on
  peri_count++;
  if( peri_count >= peri_max ) {
    blink = !blink;
    digitalWrite(RELAY3_PIN,blink);
    peri_count = 0;
  }
}
else {
  blink = LOW;
  digitalWrite(RELAY3_PIN,blink) ;
}

if( digitalRead(RELAY2_PIN) == HIGH) {  // set new duration of blink / no blink time
  if (rel_old == LOW) peri_set = 0;
  if (peri_set <= peri_set_max) {
    peri_set++;
  }
}
else {
  peri_max = peri_set/5;
}
rel_old = digitalRead(RELAY2_PIN);

  bool poll = sdev.pollRadio();
  if ( worked == false && poll == false ) {
    hal.activity.savePower<Idle<> >(hal);
  }
}

viele Grüße
Werner


McShire

die devices dazu in FHEM sind:

Internals:
   CUL868T_MSGCNT 675
   CUL868T_RAWMSG A0E1A86101209010000000602000000::-71:CUL868T
   CUL868T_RSSI -71
   CUL868T_TIME 2020-12-27 19:29:30
   DEF        120901
   FUUID      5fc424c1-f33f-f21b-d69b-86c14c2f70c649b8
   IODev      CUL868T
   LASTInputDev CUL868T
   MSGCNT     675
   NAME       HM_120901
   NOTIFYDEV  global
   NR         836
   NTFY_ORDER 50-HM_120901
   STATE      CMDs_done
   TYPE       CUL_HM
   channel_01 HM_120901_Sw_01
   channel_02 HM_120901_Sw_02
   lastMsg    No:1A - t:10 s:120901 d:000000 0602000000
   protCmdDel 5
   protLastRcv 2020-12-27 19:29:30
   protRcv    675 last_at:2020-12-27 19:29:30
   protResnd  16 last_at:2020-12-26 22:31:47
   protResndFail 4 last_at:2020-12-26 22:31:53
   protSnd    43 last_at:2020-12-27 18:19:54
   protState  CMDs_done
   rssi_CUL868T cnt:39 min:-79 max:-59 avg:-69.25 lst:-61
   rssi_at_CUL868T cnt:675 min:-85 max:-57.5 avg:-68.48 lst:-71
   rssi_broadcast cnt:257 min:-89 max:-51 avg:-70.96 lst:-78
   READINGS:
     2020-12-27 18:19:48   D-firmware      2.4
     2020-12-27 18:19:48   D-serialNr      JPLCSw2001
     2020-12-01 21:59:01   PairedTo        0x000000
     2020-12-01 21:59:01   RegL_00.        00:00 02:01 0A:00 0B:00 0C:00
     2020-12-01 21:59:01   cfgState        updating
     2020-12-27 18:19:54   commState       CMDs_done
     2020-12-01 21:58:46   powerOn         2020-12-01 21:58:46
     2020-12-27 18:19:54   state           CMDs_done
   helper:
     HM_CMDNR   26
     cSnd       112802471209010202000000,01280247120901010E
     mId        00CB
     peerFriend
     peerOpt    -:switch
     regLst     0
     rxType     1
     supp_Pair_Rep 0
     cmds:
       TmplKey    :no:1609089593.41341
       TmplTs     1609089593.41341
       cmdKey     0:1:0::HM_120901:00CB:00:
       cmdLst:
         assignHmKey noArg
         clear      [(readings|trigger|register|oldRegs|rssi|msgEvents|{msgErrors}|attack|all)]
         deviceRename -newName-
         fwUpdate   -filename- [-bootTime-]
         getConfig  noArg
         getDevInfo noArg
         getRegRaw  (List0|List1|List2|List3|List4|List5|List6) [-peerChn-]
         getVersion noArg
         pair       noArg
         raw        -data- [...]
         regBulk    -list-.-peerChn- -addr1:data1- -addr2:data2-...
         regSet     [(prep|{exec})] -regName- -value- [-peerChn-]
         reset      noArg
         tplDel     -tplDel-
         unpair     noArg
       lst:
         condition  slider,0,1,255
         peer       
         peerOpt   
         tplDel     
       rtrvLst:
         cmdList    [({short}|long)]
         deviceInfo [({short}|long)]
         param      -param-
         reg        -addr- -list- [-peerChn-]
         regList    noArg
         regTable   noArg
         regVal     -addr- -list- [-peerChn-]
         saveConfig [-filename-]
         tplInfo    noArg
     expert:
       def        0
       det        0
       raw        1
       tpl        0
     io:
       newChn     +120901,00,00,00
       nextSend   1609093770.73532
       prefIO     
       rxt        0
       vccu       
       p:
         120901
         00
         00
         00
     mRssi:
       mNo        1A
       io:
         CUL868T:
           -69
           -69
     prt:
       bErr       0
       sProc      0
     q:
       qReqConf   
       qReqStat   
     role:
       dev        1
       prs        1
     rssi:
       CUL868T:
         avg        -69.2564102564103
         cnt        39
         lst        -61
         max        -59
         min        -79
       at_CUL868T:
         avg        -68.4851851851851
         cnt        675
         lst        -71
         max        -57.5
         min        -85
       broadcast:
         avg        -70.9688715953308
         cnt        257
         lst        -78
         max        -51
         min        -89
     tmpl:
Attributes:
   IODev      CUL868T
   alias      HM-LC-Sw2-FM-WS-locSwitch-FHEM-v1 (HM_120901)
   autoReadReg 4_reqStatus
   comment    Sketchbook\HM-LC-Sw2-WS-locSwitch-FHEM-v1\HM-LC-Sw2-FM-WS-locSwitch-FHEM-v1.ino
Ein Funk-Schaltaktor (2-Relais), der hinter einem Lichtschalter
verwendet werden kann. Die Relais können remote mit FHEM ein- und ausgeschaltet werden und lokal durch Lichtschalter oder Taster. Die Lichtschalter müssen dabei den Pin 9 bzw.Pin7 nach Masse schalten und damit die Relais für das Licht ein und ausschalten.

   expert     rawReg
   firmware   2.4
   model      HM-LC-SW2-FM
   room       CUL_HM,Schalter,Test
   serialNr   JPLCSw2001
   subType    switch
   webCmd     getConfig:clear msgEvents


und die Kanäle

Internals:
   DEF        12090101
   FUUID      5fc424c1-f33f-f21b-096b-ac03015cdf8fa191
   NAME       HM_120901_Sw_01
   NOTIFYDEV  global
   NR         838
   NTFY_ORDER 50-HM_120901_Sw_01
   STATE      on
   TYPE       CUL_HM
   chanNo     01
   device     HM_120901
   peerList   self01,
   READINGS:
     2020-12-27 14:36:55   CommandAccepted yes
     2020-12-01 21:59:07   RegL_01.        00:00 08:00 30:06 56:00 57:24
     2020-12-01 21:59:17   RegL_03.self01  00:00 02:00 03:00 04:32 05:64 06:00 07:FF 08:00 09:FF 0A:01 0B:14 0C:63 82:00 83:00 84:32 85:64 86:00 87:FF 88:00 89:FF 8A:01 8B:14 8C:63
     2020-12-01 21:59:01   cfgState        updating
     2020-12-27 19:28:44   deviceMsg       on (to broadcast)
     2020-12-27 19:28:44   level           100
     2020-12-27 19:28:44   pct             100
     2020-12-23 20:38:29   peerList        self01,
     2020-12-27 19:28:44   recentStateType info
     2020-12-27 19:28:44   state           on
     2020-12-27 19:28:44   timedOn         off
     2020-12-27 14:36:55   trigLast        fhem:02
   helper:
     peerFriend peerSens,peerVirt
     peerOpt    3:switch
     regLst     1,3p
     cmds:
       TmplKey    self01,:no:1609089593.41004
       TmplTs     1609089593.41004
       cmdKey     1:0:0::HM_120901:00CB:01:self01,
       cmdLst:
         clear      [(readings|trigger|register|oldRegs|rssi|msgEvents|{msgErrors}|attack|all)]
         eventL     -peer- -cond-
         eventS     -peer- -cond-
         getConfig  noArg
         getRegRaw  (List0|List1|List2|List3|List4|List5|List6) [-peerChn-]
         inhibit    [(on|{off})]
         off        noArg
         on         noArg
         on-for-timer -ontime-
         on-till    -time-
         peerBulk   -peer1,peer2,...- [({set}|unset)]
         peerIODev  [IO] -btn- [({set}|unset)] 'not for future use'
         peerSmart  -peerOpt-
         press      [(long|{short})] [(-peer-|{self01})] [(-repCount-|{0})] [(-repDelay-|{0.25})]
         pressL     [(-peer-|{self01})]
         pressS     [(-peer-|{self01})]
         regBulk    -list-.-peerChn- -addr1:data1- -addr2:data2-...
         regSet     [(prep|{exec})] -regName- -value- [-peerChn-]
         sign       [(on|{off})]
         statusRequest noArg
         toggle     noArg
         tplDel     -tplDel-
       lst:
         condition  slider,0,1,255
         peer       self01
         peerOpt    HM_001A00,HM_075F02_Sw_01,HM_075F02_Sw_02,HM_075F02_Sw_03,HM_6B5B22,HM_6B5CAD,HM_6B5D88,HM_6B5DDC,HM_6B5DE9,HM_6B5E1A,HM_6B5E1D,HM_6B5E2A,HM_6B9B29,HM_6B9B30,HM_6B9B51,HM_6C1515,HM_789012_Btn_01,HM_789012_Btn_02,HM_789012_Btn_03,HM_789012_Btn_04,HM_789015_Btn_01,HM_789015_Btn_02,HM_789015_Btn_03,HM_789015_Btn_04,Virtual_HM_Dummy_Btn1,Virtual_HM_Dummy_Btn2,Virtual_HM_Dummy_Btn3,Virtual_HM_Dummy_Btn4,Virtual_HM_Dummy_Btn5,Virtual_HM_Dummy_Btn6,Virtual_HM_Dummy_Btn7,Virtual_HM_Dummy_Btn8
         tplDel     
       rtrvLst:
         cmdList    [({short}|long)]
         deviceInfo [({short}|long)]
         param      -param-
         reg        -addr- -list- [-peerChn-]
         regList    noArg
         regTable   noArg
         regVal     -addr- -list- [-peerChn-]
         saveConfig [-filename-]
         tplInfo    noArg
     expert:
       def        0
       det        0
       raw        1
       tpl        0
     role:
       chn        1
     tmpl:
Attributes:
   comment    Ein Funk-Schaltaktor (Relais), der hinter einem Lichtschalter
verwendet werden kann. Das Relais kann remote mit FHEM ein- und ausgeschaltet werden und lokal durch den Lichtschalter. Der Lichtschalter muss dabei den Pin 9 nach Masse schalten und das Relais das Licht ein und ausschalten.
Ist ein Kanal von HM_120901 (Sketchbook\HM-LC-Sw2-FM-WS-locSwitch-FHEM-v1\HM-LC-Sw2-FM-WS-locSwitch-FHEM-v1.ino
   model      HM-LC-SW2-FM
   peerIDs    00000000,12090101,
   room       Schalter,Test
   webCmd     statusRequest:toggle:on:off


viel Spass und Erfolg.
Gruß
Werner


Tom Major

@papa
ich möchte für meine Version des Wassermelders (mit ADC Messung, Platine ist fertig und im Teststadium)
https://github.com/TomMajor/SmartHome/blob/master/HB-SEC-WDS-2/Arduino/HB-SEC-WDS-2.ino
eine per user define umschaltbare Version machen, die dann nicht mehr genau das Originalgerät für die Zentrale abbildet sondern 2 Byte extra Daten für die Batt.spannung in mV ähnlich dem HB-UNI-Sensor1 in der CCU darstellt.
Die xml Seite auf der CCU bekomme ich vermutlich hin, aber wie mache ich das am Elegantesten in der AskSinPP?

ich habe hier bei dir was entdeckt was mir vielleicht in der Richtung helfen würde (patchStatus)
https://github.com/pa-pa/AskSinPP/blob/master/ContactState.h#L136-L141

Könnten wir in StateGenericChannel z.B. 2 zusätzliche Methoden machen

setExtraDataSize(uint8_t size)
updateExtraData(uint8_t size, uint8_t* data)


Dabei soll setExtraDataSize(uint8_t size) der Klasse *permanent* mitteilen dass bei jedem Senden immer size Bytes hinten anzufügen sind.
updateExtraData() macht dann bei Bedarf das Update vor dem Senden.
Wäre das ein brauchbares Konzept? Soll ich einen PR dafür machen?

Danke,
Früher: FHEM 5.x
Jetzt: RaspberryMatic / ioBroker

papa

Das wären dann 2 zusätziche virtuelle Methoden, die zusätzlich Platz im RAM brauchen. Das würde ich wenn möglich verhindern wollen. Warum geht die patchStatus-Lösung nicht ?
BananaPi + CUL868 + CUL433 + HM-UART + 1Wire

Tom Major

Zitat von: papa am 28 Dezember 2020, 19:42:05
Das wären dann 2 zusätziche virtuelle Methoden, die zusätzlich Platz im RAM brauchen. Das würde ich wenn möglich verhindern wollen. Warum geht die patchStatus-Lösung nicht ?

Das verstehe ich natürlich mit dem zusätzlichen Platz für diesen Spezialfall.
Aber dann könnten wir das doch mit einem #ifdef lösen so wie du jetzt bei CONTACT_STATE_WITH_BATTERY ? Das könnte ich ja alles erst mal lokal vorbereiten und testen ob es überhaupt das gewünschte Resultat liefert.

Und ich brauche eine universelle Methode für append custom data mit ggf. mehren Bytes, nicht fest auf battery().current().

Finde auch kein Bsp. zur Verwendung von patchStatus() aus einem Sketch heraus und verstehe es nicht wirklich. Mein Problem ist ja das der Wassermelder keinen direkten Zugriff auf die msg hat, aber patchStatus erwartet die msg als Parameter.

Wie müsste der Code in der Klasse StateGenericChannel aussehen, um 2 Byte anzuhängen, das ist mir ein Rätsel:

updateExtraData(uint8_t size, uint8_t* data) {
  for (uint8_t i = 0; i < size; i++) {
    // append data[i] to send msg, aber wie ??
  }
}
Früher: FHEM 5.x
Jetzt: RaspberryMatic / ioBroker

papa

patchStatus wird immer vom Device aufgerufen, wenn der Gerätestatus gesendet wird

https://github.com/pa-pa/AskSinPP/blob/ca9518b5b70d7b95daeede0f2c5053a98db8e0f7/Device.h#L357
https://github.com/pa-pa/AskSinPP/blob/ca9518b5b70d7b95daeede0f2c5053a98db8e0f7/Device.h#L391

Du kannst diese Method in "Deinen" Channel überschreiben und dort anhängen, was immer Du willst. Die Message wird vom Device vorher initialisiert.
BananaPi + CUL868 + CUL433 + HM-UART + 1Wire

papa

Man könnte aber auch die Sensor-Klasse (erstes Templateargument im StateGenericChannel) um eine weitere Methode erweitern, diese kriegt dann die Message und kann extra Daten anhängen. Alle bestehenden Sensoren kriegen eine leere Implementierung - dann ist das auch schön rückwärts kompatibel.
BananaPi + CUL868 + CUL433 + HM-UART + 1Wire