Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filling the rfmode array for the attribute list. #1047

Merged
merged 17 commits into from
Dec 20, 2021
Merged

Conversation

elektron-bbs
Copy link
Contributor

@elektron-bbs elektron-bbs commented Dec 10, 2021

  • Please check if the PR fulfills these requirements
  • Tests for the changes have been added / modified (needed for for bug fixes / features)
  • commandref has been added / updated (needed for bug fixes / features)
  • What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
  • Bugfix (please link issue)
  • Feature enhancement
  • Documentation update
  • Unittest enhancement
  • other
  • What is the current behavior?
    (You can also link to an open issue here, if this describes the current behavior)
    Array rfmode must be added manually.
    rfmode - from SD_ProtocolData.pm #980

  • What is the new behavior (if this is a feature change)?
    The rfmode array is filled with the data from SD_ProtocolData.pm.

  • Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)
    no

  • Other information:

@codecov
Copy link

codecov bot commented Dec 10, 2021

Codecov Report

Merging #1047 (a1306ce) into master (cac1dc5) will increase coverage by 0.07%.
The diff coverage is 82.75%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1047      +/-   ##
==========================================
+ Coverage   61.37%   61.45%   +0.07%     
==========================================
  Files         124      128       +4     
  Lines        9298     9396      +98     
  Branches     1473     1484      +11     
==========================================
+ Hits         5707     5774      +67     
- Misses       2523     2543      +20     
- Partials     1068     1079      +11     
Flag Coverage Δ
fhem 52.75% <75.00%> (+0.18%) ⬆️
modules 61.45% <82.75%> (+0.07%) ⬆️
perl 91.61% <92.30%> (-0.14%) ⬇️
unittests 61.45% <82.75%> (+0.07%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
FHEM/00_SIGNALduino.pm 63.00% <66.66%> (-0.82%) ⬇️
FHEM/lib/SD_Protocols.pm 79.15% <75.00%> (-0.37%) ⬇️
t/FHEM/00_SIGNALduino/00_SIGNALduino_initialize.t 100.00% <100.00%> (ø)
t/SD_Protocols/01_func.t 100.00% <100.00%> (ø)
t/FHEM/14_SD_BELL/09_parseDatat.t 80.00% <0.00%> (ø)
t/FHEM/14_FLAMINGO/09_parseDatat.t 80.00% <0.00%> (ø)
t/FHEM/14_SD_UT/09_parseDatat.t 80.00% <0.00%> (ø)
FHEM/10_SD_Rojaflex.pm 71.54% <0.00%> (+2.84%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cac1dc5...a1306ce. Read the comment docs.

@HomeAutoUser
Copy link
Contributor

@sidey79, was hälst du von dem Vorschlag von @elektron-bbs hier?

@sidey79
Copy link
Contributor

sidey79 commented Dec 13, 2021

@sidey79, was hälst du von dem Vorschlag von @elektron-bbs hier?

Ich finde es gut, rfmode dynamisch zu generieren.
Das muss meiner Einschätzung aber nur einmal beim Laden des Modules passieren und nicht bei jeder Instanz.

Mit dieser Anpassung wird der protocol Hash auch mehrfach geladen, obwohl er identisch ist.

Da es um Daten aus SD_Protocols geht, würde ich auch eher getKeys so erweitern, dass wir dort noch ein Value mitgeben welches vorhanden sein muss, so eine Art Filter.

@elektron-bbs
Copy link
Contributor Author

Ich finde es gut, rfmode dynamisch zu generieren. Das muss meiner Einschätzung aber nur einmal beim Laden des Modules passieren und nicht bei jeder Instanz.

Das war eigentlich schon der Fall. Die sub SIGNALduino_Initialize wird nur einmal ausgeführt.

Mit dieser Anpassung wird der protocol Hash auch mehrfach geladen, obwohl er identisch ist.

Das sollte jetzt nicht mehr der Fall sein.

Da es um Daten aus SD_Protocols geht, würde ich auch eher getKeys so erweitern, dass wir dort noch ein Value mitgeben welches vorhanden sein muss, so eine Art Filter.

Ich habe dafür jetzt checkProperty verwendet, da bekommen wir ja bereits den Wert geliefert.

getKeys um eine Filterfunktion erweitert
Zusammensetzen von rfmode vereindacht
@sidey79
Copy link
Contributor

sidey79 commented Dec 17, 2021

Ich habe getKeys mal erweitert und das verwendet.
Spaar einiges an Codezeilen und lässt sich an anderen Stellen auch noch einsetzen.

Ich bin aber immer noch der Meinung dass SIGNALduino_Initialize für jede Definition aufgerufen wird.

@elektron-bbs
Copy link
Contributor Author

Ich habe getKeys mal erweitert und das verwendet. Spaar einiges an Codezeilen und lässt sich an anderen Stellen auch noch einsetzen.

Zeigst du uns den Code?

Ich bin aber immer noch der Meinung dass SIGNALduino_Initialize für jede Definition aufgerufen wird.

Dagegen spricht aber, das die Logausgaben (noch aus meinen Tests) nur genau einmal im Log auftauchen:

2021.12.14 20:42:42 1: Including fhem.cfg
2021.12.14 20:42:42 3: WEB: port 8083 opened
2021.12.14 20:42:43 2: eventTypes: loaded 13944 lines from ./log/eventTypes.txt
2021.12.14 20:42:43 1: ####################### TEST rfmode #######################
2021.12.14 20:42:44 1: SIGNALduino_Initialize: search rfmode in protocols, found ID 103 -> Lacrosse_mode2
2021.12.14 20:42:44 1: SIGNALduino_Initialize: search rfmode in protocols, found ID 100 -> Lacrosse_mode1
2021.12.14 20:42:44 1: SIGNALduino_Initialize: search rfmode in protocols, found ID 109 -> Rojaflex
2021.12.14 20:42:44 1: SIGNALduino_Initialize: search rfmode in protocols, found ID 107.1 -> Fine_Offset_WH51_868
2021.12.14 20:42:44 1: SIGNALduino_Initialize: search rfmode in protocols, found ID 102 -> KOPP_FC
2021.12.14 20:42:44 1: SIGNALduino_Initialize: search rfmode in protocols, found ID 115 -> Bresser_6in1
2021.12.14 20:42:44 1: SIGNALduino_Initialize: search rfmode in protocols, found ID 107 -> Fine_Offset_WH51_434
2021.12.14 20:42:44 1: SIGNALduino_Initialize: search rfmode in protocols, found ID 116 -> Fine_Offset_WH57
2021.12.14 20:42:44 1: SIGNALduino_Initialize: search rfmode in protocols, found ID 994 -> Lacrosse_mode4
2021.12.14 20:42:44 1: SIGNALduino_Initialize: search rfmode in protocols, found ID 101 -> PCA301
2021.12.14 20:42:44 1: SIGNALduino_Initialize: search rfmode in protocols, found ID 112 -> Avantek
2021.12.14 20:42:44 1: SIGNALduino_Initialize: search rfmode in protocols, found ID 108 -> Bresser_5in1
2021.12.14 20:42:44 1: SIGNALduino_Initialize: search rfmode in protocols, found ID 200 -> WMBus_T
2021.12.14 20:42:44 1: SIGNALduino_Initialize: rfmode list: Avantek Bresser_5in1 Bresser_6in1 Fine_Offset_WH51_434 Fine_Offset_WH51_868 Fine_Offset_WH57 KOPP_FC Lacrosse_mode1 Lacrosse_mode2 Lacrosse_mode4 PCA301 Rojaflex SlowRF WMBus_T
2021.12.14 20:42:44 1: ####################### TEST rfmode fertig #######################
2021.12.14 20:42:44 3: Opening sduinoIP device 192.168.178.46:23

@sidey79 sidey79 linked an issue Dec 18, 2021 that may be closed by this pull request
@sidey79
Copy link
Contributor

sidey79 commented Dec 18, 2021

Zeigst du uns den Code?

Ich dachte ich hätte ihn gestern abend noch gepusht. Wenn nicht, dann ist er jetzt defintiv im Repo.

Ich bin aber immer noch der Meinung dass SIGNALduino_Initialize für jede Definition aufgerufen wird.

Dagegen spricht aber, das die Logausgaben (noch aus meinen Tests) nur genau einmal im Log auftauchen:

Okay, Du hast natürlich recht. Der Variablenname $hash hat mich einfach mal wieder in die Irre geführt.

@elektron-bbs
Copy link
Contributor Author

OK, jetzt habe ich die Änderungen gefunden. Sieht gut aus, aber ich würde das Array noch sortieren:

    push @rfmode, map { $Protocols->checkProperty($_,'rfmode') } $Protocols->getKeys('rfmode');
    @rfmode = sort @rfmode;

sonst ist das durcheinander:
rfmode

@sidey79
Copy link
Contributor

sidey79 commented Dec 19, 2021

@rfmode = sort @rfmode;

Ah ja, daran habe ich nicht gedacht, dass der Grund des Sortierens in der Anzeige steckt. :)

@sidey79
Copy link
Contributor

sidey79 commented Dec 19, 2021

Hmm, irgdnwie sind manche Attribute doppelt vorhanden :-(

rfmode:Avantek,Avantek,Bresser_5in1,Bresser_5in1,Bresser_6in1,Bresser_6in1,KOPP_FC,KOPP_FC,Lacrosse_mode1,Lacrosse_mode1,Lacrosse_mode2,Lacrosse_mode2,PCA301,PCA301,Rojaflex,Rojaflex,SlowRF 

@HomeAutoUser
Copy link
Contributor

Ich würde das push erweitern, nur wenn das Attribut noch nicht im Array ist.

sidey79 and others added 3 commits December 19, 2021 19:07
Added check for correct sorted order of elements in rfmode
array rfmode wird in SIGNALduino_Initialize und nicht mehr global mit Wert initialisiert.
@sidey79
Copy link
Contributor

sidey79 commented Dec 19, 2021

Ich würde das push erweitern, nur wenn das Attribut noch nicht im Array ist.

Ich habe es ein wenig anders gelöst. Das Problem lag daran, dass FHEM ja SIGNALduino_Initialize aufruft sobald das Modul geladen wird und wenn es erneut aufgerufen wird, dann erweitert es die rfmode Liste.

Ich habe den Default von @RFmode in die sub verfrachtet, dadurch wird @RFmode vor jedem Aufruf immer auf den identischen Default gesetzt.

@elektron-bbs
Copy link
Contributor Author

Ich habe es ein wenig anders gelöst. Das Problem lag daran, dass FHEM ja SIGNALduino_Initialize aufruft sobald das Modul geladen wird und wenn es erneut aufgerufen wird, dann erweitert es die rfmode Liste.

Mhmm, wann wird das SIGNALduino-Modul denn erneut aufgerufen?

Ich habe den Default von @RFmode in die sub verfrachtet, dadurch wird @RFmode vor jedem Aufruf immer auf den identischen Default gesetzt.

So geht es natürlich auch.

@sidey79
Copy link
Contributor

sidey79 commented Dec 19, 2021

Mhmm, wann wird das SIGNALduino-Modul denn erneut aufgerufen?

Das passiert durch den Test aber auch durch jedes commandReload.

Copy link
Contributor

@sidey79 sidey79 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aus meiner Sicht spricht können wir das so übernehmen :)

@elektron-bbs elektron-bbs merged commit e5ee788 into master Dec 20, 2021
@elektron-bbs elektron-bbs deleted the master_rfmode branch January 23, 2022 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rfmode - from SD_ProtocolData.pm
4 participants