diff --git a/fhem/t/FHEM/98_PHC/10_Parse.cfg b/fhem/t/FHEM/98_PHC/10_Parse.cfg new file mode 100644 index 000000000..5e043ad66 --- /dev/null +++ b/fhem/t/FHEM/98_PHC/10_Parse.cfg @@ -0,0 +1,15 @@ + +define PHC PHC none +attr PHC verbose 5 +attr PHC EMDReadings 1 +attr PHC channelEMD12i00description Arbeiten - neben Türe oben - Deckenlicht (rot) +attr PHC channelAMD03o00description Wohnen - Auslass über Bar / Aquarium +attr PHC channelAMD03o01description Arbeiten - Deckenlampe Mitte +attr PHC channelAMD03o02description Arbeiten - Lampenschiene +attr PHC channelAMD03o03description Flur EG - Deckenspots +attr PHC channelAMD03o04description Garderobe - Deckenlampe +attr PHC channelAMD03o05description WC EG - Spiegellampe +attr PHC channelAMD03o06description Schuhe - Deckenlampe +attr PHC channelAMD03o07description Treppe EG-UG - Wandlampen +attr PHC virtEMD26C10Name AZLicht + diff --git a/fhem/t/FHEM/98_PHC/10_Parse.t b/fhem/t/FHEM/98_PHC/10_Parse.t new file mode 100644 index 000000000..6be693859 --- /dev/null +++ b/fhem/t/FHEM/98_PHC/10_Parse.t @@ -0,0 +1,45 @@ +############################################## +# test parsing +############################################## + +use strict; +use warnings; +use Test::More; + +my $hash = $defs{'PHC'}; +$hash->{helper}{buffer} = pack ('H*', '0c011224490c0100b77a4301463411430200062a1f'); +PHC::ParseFrames($hash); + +is(FhemTestUtils_gotEvent("EMD12i01: Ein > 0"), 1, "EMD Event"); +is(FhemTestUtils_gotEvent("Arbeiten-Deckenlampe_Mitte: 1"), 1, "AMD Feedback Event 1"); +is(FhemTestUtils_gotEvent("Wohnen-Auslass_ueber_Bar_Aquarium: 0"), 1, "AMD Feedback Event 2"); + +fhem ('set PHC AZLicht ein>0'); +is(FhemTestUtils_gotLog("PHC: sends 1a01a2e3af"), 1, "sending virtual EMD"); + +fhem 'attr PHC verbose 5'; +$hash->{helper}{buffer} = pack ('H*', '0d04408101274440820140e108400101ebc8400201400d04408101274440820140e108400101ebc8400201400d04408101274440820140e108400101ebc8400201400d04408101274440820140e108400101ebc8400201400d04408101274440820140e108400101ebc8400201400d04408101274440820140e108400101ebc8400201400d04408101274440820140e108400101ebc8400201400d04408101274440820140e108400101ebc8400201400d04408101274440820140e108400101ebc8400201400d04408101274440820140e108400101ebc8400201400d04408101274440820140e108400101ebc8400201400d04408101274440820140e108'); +PHC::ParseFrames($hash); +# todo: check + + +$hash->{helper}{buffer} = pack ('H*', 'a183086700cbc8a18200818d6e'); +PHC::ParseFrames($hash); +is(FhemTestUtils_gotEvent("DIM01o00: Heller Dimmen"), 1, "DIM Event"); + + +$hash->{helper}{buffer} = pack ('H*', 'a18309070042f7a18200818d6e'); +PHC::ParseFrames($hash); +is(FhemTestUtils_gotEvent("DIM01o00: Dunkler Dimmen"), 1, "DIM Event2"); + + +done_testing; + +exit(0); + +1; + + + + + diff --git a/fhem/t/FHEM/98_PHC/20_Import.cfg b/fhem/t/FHEM/98_PHC/20_Import.cfg new file mode 100644 index 000000000..93eb19495 --- /dev/null +++ b/fhem/t/FHEM/98_PHC/20_Import.cfg @@ -0,0 +1,3 @@ + +define PHC PHC none +attr PHC verbose 5 diff --git a/fhem/t/FHEM/98_PHC/20_Import.t b/fhem/t/FHEM/98_PHC/20_Import.t new file mode 100644 index 000000000..19301420c --- /dev/null +++ b/fhem/t/FHEM/98_PHC/20_Import.t @@ -0,0 +1,23 @@ +############################################## +# test parsing +############################################## + +use strict; +use warnings; +use Test::More; + +fhem ("set PHC importChannelList $attr{global}{modpath}/t/FHEM/98_PHC/Kanalliste1.xml"); +is(FhemTestUtils_gotLog("Attr called with set PHC module009description EG 230 1"), 1, "description attr from module"); +is(FhemTestUtils_gotLog("Attr called with set PHC channelEMD09i00description BWM Wand Arbeiten zum Garten hin"), 1, "description attr from input"); +is(FhemTestUtils_gotLog("Attr called with set PHC channelJRM13o06description Zeitmessung Dimmer nach Leinwand"), 1, "description attr from timer"); +is(FhemTestUtils_gotLog("Attr called with set PHC channelMFM24o01description Funkausgang - 01"), 1, "description attr from output"); + +fhem ("set PHC importChannelList $attr{global}{modpath}/t/FHEM/98_PHC/Kanalliste2.xml"); +is(FhemTestUtils_gotLog("Attr called with set PHC channelEMD00i01description Wälzpumpe Warmwasser"), 1, "description attr from input"); +is(FhemTestUtils_gotLog("Attr called with set PHC module001description Eingangsmodul 24V -01"), 1, "description attr from module"); +is(FhemTestUtils_gotLog("Attr called with set PHC channelEMD00o00description LED Ausgang"), 1, "description attr from EMD output"); + +done_testing; +exit(0); + +1; diff --git a/fhem/t/FHEM/98_PHC/30_Set.cfg b/fhem/t/FHEM/98_PHC/30_Set.cfg new file mode 100644 index 000000000..7e17f3ba1 --- /dev/null +++ b/fhem/t/FHEM/98_PHC/30_Set.cfg @@ -0,0 +1,33 @@ + +define PHC PHC none +attr PHC verbose 5 +attr PHC EMDReadings 1 +attr PHC channelEMD12i00description Arbeiten - neben Türe oben - Deckenlicht (rot) +attr PHC channelAMD03o00description Wohnen - Auslass über Bar / Aquarium +attr PHC channelAMD03o01description Arbeiten - Deckenlampe Mitte + +attr PHC channelAMD03o02description Arbeiten-Lampenschiene +attr PHC channelAMD03o02set 1 + +attr PHC channelAMD03o03description Flur EG - Deckenspots +attr PHC channelAMD03o04description Garderobe - Deckenlampe +attr PHC channelAMD03o05description WC EG - Spiegellampe +attr PHC channelAMD03o06description Schuhe - Deckenlampe +attr PHC channelAMD03o07description Treppe EG-UG - Wandlampen +attr PHC virtEMD26C10Name AZLicht + +attr PHC channelJRM22o01description Rollade AZ Teich +attr PHC channelJRM22o01set 1 +attr PHC channelJRM22o02description Rollade AZ Hinten +attr PHC channelJRM22o02set 1 + +attr PHC channelDIM05o00description Wohnen Deckenleuchte am Kamin +attr PHC channelDIM05o00set 1 +attr PHC channelDIM05o01description Wohnen Deckenleuchte zum Essbereich +attr PHC channelDIM05o01set 1 + +define PHCService HTTPMOD http://192.168.70.7:6680/ 0 +attr PHCService verbose 5 + +#attr PHC HTTPMOD PHCService + diff --git a/fhem/t/FHEM/98_PHC/30_Set.t b/fhem/t/FHEM/98_PHC/30_Set.t new file mode 100644 index 000000000..fc6e453fd --- /dev/null +++ b/fhem/t/FHEM/98_PHC/30_Set.t @@ -0,0 +1,88 @@ +############################################## +# test parsing +############################################## + +use strict; +use warnings; +use Test::More; +use FHEM::Modbus::TestUtils qw(:all); + +fhem 'attr global mseclog 1'; +NextStep(); + +sub testStep1 { + CheckAndReset(); + fhem 'set PHC JRM22o1 senken'; + return 0.1; +} + +sub testStep2 { + is(FhemTestUtils_gotLog("XMLRPC called with service.stm.sendTelegram and 0x00,0x56,0x26,0x03,0x58,0x02"), 1, "got XMLRPC Log"); +} + + +sub testStep10 { + CheckAndReset(); + fhem 'set PHC JRM22o1 senken prio=2 set=1 time=50'; + return 0.1; +} + +sub testStep11 { + is(FhemTestUtils_gotLog("XMLRPC called with service.stm.sendTelegram and 0x00,0x56,0x26,0x42,0x32,0x00"), 1, "got XMLRPC Log"); +} + + +sub testStep20 { + CheckAndReset(); + fhem 'set PHC Rollade_AZ_Teich senken prio=2 set=1 time=50'; + return 0.1; +} + +sub testStep21 { + is(FhemTestUtils_gotLog("XMLRPC called with service.stm.sendTelegram and 0x00,0x56,0x26,0x42,0x32,0x00"), 1, "got XMLRPC Log"); +} + + +sub testStep30 { + CheckAndReset(); + #fhem 'attr PHC HTTPMOD PHCService'; + fhem 'set PHC Wohnen_Deckenleuchte_am_Kamin Dunkler Dimmen time=10'; + return 0.1; +} + +sub testStep31 { + is(FhemTestUtils_gotLog("XMLRPC called with service.stm.sendTelegram and 0x00,0xA5,0x09,0x0F,0x00"), 1, "got XMLRPC Log"); +} + + +sub testStep50 { + CheckAndReset(); + fhem 'set PHC Arbeiten-Lampenschiene An_mit_Timer time=5'; + return 0.1; +} + +sub testStep51 { + is(FhemTestUtils_gotLog("XMLRPC called with service.stm.sendTelegram and 0x00,0x43,0x4A,0x05,0x00"), 1, "got XMLRPC Log"); +} + + +sub testStep60 { + CheckAndReset(); + #fhem 'attr PHC HTTPMOD PHCService'; + fhem 'set PHC Arbeiten-Lampenschiene An mit Timer time=5'; + return 0.1; +} + +sub testStep61 { + is(FhemTestUtils_gotLog("XMLRPC called with service.stm.sendTelegram and 0x00,0x43,0x4A,0x05,0x00"), 1, "got XMLRPC Log"); +} + + +sub testStep90 { + CheckAndReset(); + fhem 'set PHC ?'; + return 0.1; +} + + +1; diff --git a/fhem/t/FHEM/98_PHC/Kanalliste1.xml b/fhem/t/FHEM/98_PHC/Kanalliste1.xml new file mode 100644 index 000000000..83a34e997 --- /dev/null +++ b/fhem/t/FHEM/98_PHC/Kanalliste1.xml @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fhem/t/FHEM/98_PHC/Kanalliste2.xml b/fhem/t/FHEM/98_PHC/Kanalliste2.xml new file mode 100644 index 000000000..0c2d888dd --- /dev/null +++ b/fhem/t/FHEM/98_PHC/Kanalliste2.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + +