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

Added Module to Support LTECH #1098

Open
wants to merge 57 commits into
base: master
Choose a base branch
from
Open

Added Module to Support LTECH #1098

wants to merge 57 commits into from

Conversation

Devirex
Copy link
Contributor

@Devirex Devirex commented Apr 22, 2022

  • 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?
    No Modul for uknown Protocoll 31

  • What is the new behavior (if this is a feature change)?
    Module LTECH for known Protokol P31

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

  • Other information:

Devirex and others added 16 commits December 27, 2021 19:13
test

test

test

test

test

test

test

test

test

test

test

test

test

test

test

test

test

test

test

test

test

test

test

test

test

test

test

test

test

test

test

test

test

test

test

test

test

test

test

test
…ter (RFD-FHEM#1085)

SD_ProtocolData.pm - fixed packet length 18 byte
14_SD_WS.pm - new ground/earth sensor for humidity and temperature, indoor sensor for humidity and temperature
* Update 14_SD_WS09.pm

- usw CORE Time instead of global from hires
- optimzed code a little bit, removed useless checks
- few perlcritic fixes
Bumps [shogo82148/actions-setup-perl](https://github.com/shogo82148/actions-setup-perl) from 1.14.2 to 1.15.1.
- [Release notes](https://github.com/shogo82148/actions-setup-perl/releases)
- [Commits](shogo82148/actions-setup-perl@v1.14.2...v1.15.1)

---
updated-dependencies:
- dependency-name: shogo82148/actions-setup-perl
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: sidey79 <7968127+sidey79@users.noreply.github.com>
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 2 to 3.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](actions/upload-artifact@v2...v3)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: sidey79 <7968127+sidey79@users.noreply.github.com>
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 2 to 3.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](actions/download-artifact@v2...v3)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: sidey79 <7968127+sidey79@users.noreply.github.com>
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 2.1.0 to 3.0.0.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/master/CHANGELOG.md)
- [Commits](codecov/codecov-action@v2.1.0...v3.0.0)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: sidey79 <7968127+sidey79@users.noreply.github.com>
14_SD_WS.pm - new sensor TFA 30.3251.10, added CRC8 check for protocol 85
@codecov
Copy link

codecov bot commented Apr 22, 2022

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.92%. Comparing base (910f5eb) to head (2d02ef0).
Report is 58 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1098      +/-   ##
==========================================
- Coverage   89.25%   88.92%   -0.33%     
==========================================
  Files          43       43              
  Lines        2466     2466              
  Branches      170      170              
==========================================
- Hits         2201     2193       -8     
- Misses        111      119       +8     
  Partials      154      154              
Flag Coverage Δ
fhem 88.92% <ø> (-0.33%) ⬇️
modules 88.92% <ø> (-0.33%) ⬇️
perl 88.92% <ø> (-0.33%) ⬇️
unittests 88.92% <ø> (-0.33%) ⬇️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sidey79
Copy link
Contributor

sidey79 commented Apr 22, 2022

@Devirex

Danke für den PR.

In dem Modul finden sich noch Reste von einem Siri Modul. Die wolltest Du sicher noch ändern.
Die Perl critic Meldungen beziehen sich hauptsächlich auf die Prototypen aber eine auch wegen der Verwendung von Switch.

Im Detail habe ich mir den Rest jetzt nicht angesehen, grundsätzlich ist es aber so, dass Module unittests benötigen.
Vieles kann in bestehende Tests integriert werden. Manches ist aber speziell. Dafür werden wir Daten von dir benötigten.

@Devirex
Copy link
Contributor Author

Devirex commented Apr 23, 2022

Wow in der ersten Zeile gleich,
-> zu lange davor gesessen. Ich passe das an. Das mit den Tests schaue ich mir an.

@sidey79
Copy link
Contributor

sidey79 commented Apr 23, 2022

Wow in der ersten Zeile gleich, -> zu lange davor gesessen. Ich passe das an. Das mit den Tests schaue ich mir an.

Der einfachste Test prüft nur, ob das Modul geladen werden kann.
Den kannst Du aus einem anderen Modul 1:1 kopieren, dann funktioniert der schon, da er das Modul aus dem Ordnernamen verwendet.
Damit wissen wir dann, dass es keine Syntaxfehler gibt.

Die Parse Funktion wird über Testdaten geprüft.
Das suche sich dir raus, wie das geht.

Einzelne Subs bekommen in der Regel einen eigenen Test. Je nach komplexit der Sub ist das dann einfacher oder aufwändiger.

@sidey79
Copy link
Contributor

sidey79 commented Apr 24, 2022

Also

  1. Basistest ob sich das Modul überhaupt laden lässt kannst Du die folgende Datei in einen Ordnernamen identisch zu deinem Modul kopieren. Damit erhalten wir auch gleich die Information ob wir einen Syntaxfehler haben oder nicht:

https://github.com/RFD-FHEM/RFFHEM/blob/master/t/FHEM/10_SD_Rojaflex/00_load.t

In diesem Fall kommen alle Tests in den Ordner t/FHEM/14_LTECH

Damit Tests überhaupt laufen muss auch eine fhem.cfg im Testordner liegen

Diese von hier, könnte ausreichend sein:
https://github.com/RFD-FHEM/RFFHEM/blob/master/t/FHEM/10_SD_GT/fhem.cfg

2a)
Testdaten kommen hier rein: (JSON)
https://github.com/RFD-FHEM/SIGNALduino_TOOL/blob/master/FHEM/lib/SD_Device_ProtocolList.json#L2975

Sobald hier Testdaten für das Modul enthalten sind, kann ein Test diese validieren. Im groben, werden Internals und Readings deines Moduls damit validiert.

INPUT und OUTPUT sind je nach Test unterschiedlich. z.B. wird validiert ob die RMSG als input zu der angegebenen DMSG führt.
Die DMSG wiederum, wird als Input für andere Tests verwendet um zu validieren, ob ein Reading gesetzt wurde.

Einfach mal versuchen einen Testdatensatz aus RMSG und DMSG zu erstellen.
Lokal innerhalb FHEM kannst Du auch mittels des Moduls SIGNALduino_TOOL testen.

2b)
Damit die Testdaten aus 2a getestet werden, braucht es noch einen weiteren Test.
https://github.com/RFD-FHEM/RFFHEM/blob/master/t/FHEM/14_SD_UT/09_parseDatat.t

Optional können dort auch korrupte Daten getestet werden. Den Teil kommentiere ich aber erst einmal aus

Ich werde dir das gleich mal in deinen PR reinlegen, dann hast Du einen Ausgangspunkt.

added base tests for logical module
- save coderefs as reference and not as text
- save regex as compiled regex instead of string
Update id / comment / intro
@sidey79
Copy link
Contributor

sidey79 commented Apr 24, 2022

@Devirex

Wie Du siehst, ist der Test nicht erfolgreich, das Modul kann nicht geladen werden und es bricht mit einem Fehler ab:

# Failed test '14_LTECH loaded'
Error: # at /home/runner/work/RFFHEM/RFFHEM/t/FHEM/14_LTECH/00_load.t line 13.
# +---------------------------------------------------------+----+---------+
# | GOT                                                     | OP | CHECK   |
# +---------------------------------------------------------+----+---------+
# | Can't locate Switch.pm in @INC (you may need to install | IS | <UNDEF> |
# |  the Switch module) (@INC contains: ./lib ./FHEM . /hom |    |         |
# | e/runner/work/RFFHEM/RFFHEM/local/lib/perl5/5.26.3/x86_ |    |         |
# | 64-linux /home/runner/work/RFFHEM/RFFHEM/local/lib/perl |    |         |
# | 5/5.26.3 /home/runner/work/RFFHEM/RFFHEM/local/lib/perl |    |         |
# | 5/x86_64-linux /home/runner/work/RFFHEM/RFFHEM/local/li |    |         |
# | b/perl5 /home/runner/work/_actions/shogo82148/actions-s |    |         |
# | etup-perl/v1.15.1/scripts/lib /opt/hostedtoolcache/perl |    |         |
# | /5.26.3/x64/lib/site_perl/5.26.3/x86_64-linux /opt/host |    |         |
# | edtoolcache/perl/5.26.3/x64/lib/site_perl/5.26.3 /opt/h |    |         |
# | ostedtoolcache/perl/5.26.3/x64/lib/5.26.3/x86_64-linux  |    |         |
# | /opt/hostedtoolcache/perl/5.26.3/x64/lib/5.26.3) at ./F |    |         |
# | HEM/14_LTECH.pm line 57.\n                              |    |         |
# | BEGIN failed--compilation aborted at ./FHEM/14_LTECH.pm |    |         |
# |  line 57.\n                                             |    |         |
# +---------------------------------------------------------+----+---------+
/home/runner/work/RFFHEM/RFFHEM/t/FHEM/14_LTECH/00_load.t ........................................ 

Wie schon erwähnt, sollte switch ersetzt werden.
Da bietet sich eine Lookup Tabelle an um alle Kommandos abzubilden:

my %set_commands = (
# cmd switches
rgbcolor => sub { readingsSingleUpdate($hash, 'rgbcolor_sel', uc $value, 1 },
white => sub { readingsSingleUpdate($hash, 'white_sel', $value , 1},
);

Anstelle switch wird dann einfach die passende anonyme sub aufgerufen:

$set_commands {$cmd};

GGf. müssen aber noch Variable übergeben und eingelesen werden.

sidey79 and others added 4 commits April 25, 2022 14:09
Update id / comment / intro

Remove Switch Parse

Remove Switch Set

Remove Switch Set

Detect turn off

Detect turn off

Remove Switch import
Update id / comment / intro

Remove Switch Parse

Remove Switch Set

Remove Switch Set

Detect turn off

Detect turn off

Remove Switch import
Added autocreate test

Added autocreate test

Added autocreate test

Added autocreate test
@Devirex
Copy link
Contributor Author

Devirex commented Jul 21, 2022

Habe einen PR für die Testdaten erstellt:

RFD-FHEM/SIGNALduino_TOOL#76

@sidey79
Copy link
Contributor

sidey79 commented Jul 24, 2022

Ich habe den Branch aktualisiert und dabei kamen ein paar Abweichungen in den Tests zutage:

ok 1 - 14_LTECH loaded
ok
    # Failed test 'check reading for devices'
Error:     # at /home/runner/work/RFFHEM/RFFHEM/t/FHEM/14_LTECH/01_set.t line 105.
    # +--------+----+--------+
    # | GOT    | OP | CHECK  |
    # +--------+----+--------+
    # | 7F1900 | eq | 7F7F7F |
    # +--------+----+--------+
# Failed test 'Protocol 31 - set LTECH_Test_11 brightness 50'
Error: # at /home/runner/work/RFFHEM/RFFHEM/t/FHEM/14_LTECH/01_set.t line 106.
    # Failed test 'check reading for devices'
Error:     # at /home/runner/work/RFFHEM/RFFHEM/t/FHEM/14_LTECH/01_set.t line 139.
    # +--------+----+--------+
    # | GOT    | OP | CHECK  |
    # +--------+----+--------+
    # | 7F1700 | eq | 7F0000 |
    # +--------+----+--------+
# Failed test 'Protocol 31 - set LTECH_Test_11 saturation 100'
Error: # at /home/runner/work/RFFHEM/RFFHEM/t/FHEM/14_LTECH/01_set.t line 140.

FHEM/14_LTECH.pm Outdated Show resolved Hide resolved
FHEM/14_LTECH.pm Outdated Show resolved Hide resolved
FHEM/14_LTECH.pm Outdated Show resolved Hide resolved
FHEM/14_LTECH.pm Outdated Show resolved Hide resolved
FHEM/14_LTECH.pm Outdated Show resolved Hide resolved
FHEM/14_LTECH.pm Outdated Show resolved Hide resolved
@HomeAutoUser
Copy link
Contributor

@Devirex @sidey79 , ich erhebe mal die Hand, um anzufragen wo es klemmt, das es nicht weiter geht ;-)

@Devirex
Copy link
Contributor Author

Devirex commented Apr 26, 2023

@HomeAutoUser Ok, wenn von meiner Seite aus noch was fehlt dann bitte Bescheid geben

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants