Linearschalter
Linearschalter
Umsetzung eines Linearschalters mit MSwitch.
Eingang: Beliebiges Reading als numerischer Wert.
Ausgang: Wird entsprechend Linear / oder umgekehrt Linear zum Eingang geschaltet.
Folgend die Rawdefinition des MSwitchdevices und zweier Dummys (selbsterklärend)
Alle Devices werden im Raum Lineartest angelegt, die Dummy müssen zuerst angelegt werden.
defmod linearausgang dummy attr linearausgang room Lineartest attr linearausgang setList state:slider,0,1,100 attr linearausgang webCmd state setstate linearausgang state 57 setstate linearausgang 2018-06-06 18:06:12 state state 57
defmod lineareingang dummy attr lineareingang room Lineartest attr lineareingang setList state:slider,0,1,15000 attr lineareingang webCmd state setstate lineareingang 6422 setstate lineareingang 2018-06-06 18:06:12 state 6422
defmod Linearschalter MSwitch lineareingang # linearausgang FreeCmd attr Linearschalter MSwitch_Debug 0 attr Linearschalter MSwitch_Delete_Delays 1 attr Linearschalter MSwitch_Expert 0 attr Linearschalter MSwitch_Extensions 0 attr Linearschalter MSwitch_Help 0 attr Linearschalter MSwitch_Ignore_Types notify allowed at watchdog doif fhem2fhem telnet FileLog readingsGroup FHEMWEB autocreate eventtypes readingsproxy svg cul attr Linearschalter MSwitch_Include_Devicecmds 1 attr Linearschalter MSwitch_Include_MSwitchcmds 0 attr Linearschalter MSwitch_Include_Webcmds 0 attr Linearschalter MSwitch_Inforoom MSwitch attr Linearschalter MSwitch_Lock_Quickedit 1 attr Linearschalter MSwitch_Mode Notify attr Linearschalter room Lineartest setstate Linearschalter active setstate Linearschalter 2018-06-06 18:03:50 .Device_Affected FreeCmd-AbsCmd1,FreeCmd-AbsCmd2,linearausgang-AbsCmd1 setstate Linearschalter 2018-06-06 18:04:35 .Device_Affected_Details FreeCmd-AbsCmd1,cmd,cmd,{my $eingang =ReadingsVal( "lineareingang"## "state"## 0 );;my $emin=0;;my $emax=15000;;my $amin=100;;my $amax=0;;$eingang = $emin if $eingang < $emin;;$eingang = $emax if $eingang > $emax;;my $y= (($amax-$amin)/($emax-$emin)*($eingang-$emin))+$amin;;readingsSingleUpdate( $hash## "to_set"## int ($y)## 1 );;},,delay1,delay1,000000,000000,,,0,0|FreeCmd-AbsCmd2,cmd,cmd,,,delay1,delay1,000000,000000,,,0,0|linearausgang-AbsCmd1,state,no_action,[Linearschalter:to_set],,delay1,delay1,000000,000000,,,0,0 setstate Linearschalter 2018-06-06 18:06:12 .Device_Events no_trigger setstate Linearschalter 2018-06-04 18:24:21 .First_init done setstate Linearschalter 2018-06-06 18:00:47 .Trigger_cmd_off no_trigger setstate Linearschalter 2018-06-06 18:00:47 .Trigger_cmd_on * setstate Linearschalter 2018-06-06 17:58:56 .Trigger_condition setstate Linearschalter 2018-06-06 18:00:47 .Trigger_off no_trigger setstate Linearschalter 2018-06-06 18:00:47 .Trigger_on no_trigger setstate Linearschalter 2018-06-06 17:58:56 .Trigger_time setstate Linearschalter 2018-06-04 18:24:21 .V_Check V 0.3 setstate Linearschalter 2018-06-06 18:06:12 EVENT state: 6422 setstate Linearschalter 2018-06-06 18:06:12 EVTFULL lineareingang:state: 6422 setstate Linearschalter 2018-06-06 18:06:12 EVTPART1 lineareingang setstate Linearschalter 2018-06-06 18:06:12 EVTPART2 state setstate Linearschalter 2018-06-06 18:06:12 EVTPART3 6422 setstate Linearschalter 2018-06-06 18:06:12 Exec_cmd set linearausgang state [Linearschalter:to_set] setstate Linearschalter 2018-06-06 17:58:56 Trigger_device lineareingang setstate Linearschalter 2018-06-06 18:00:47 Trigger_log off setstate Linearschalter 2018-06-06 18:06:12 last_event state: 6422 setstate Linearschalter 2018-06-04 18:39:56 state active setstate Linearschalter 2018-06-06 18:06:12 to_set 57
MSwitch -Configfile (bei Bedarf)
#V V1.54 #S .Device_Affected -> FreeCmd-AbsCmd1,FreeCmd-AbsCmd2,linearausgang-AbsCmd1 #S .Device_Affected_Details -> FreeCmd-AbsCmd1,cmd,cmd,{my $eingang =ReadingsVal( "lineareingang"## "state"## 0 )[S]my $emin=0[S]my $emax=15000[S]my $amin=100[S]my $amax=0[S]$eingang = $emin if $eingang < $emin[S]$eingang = $emax if $eingang > $emax[S]my $y= (($amax-$amin)/($emax-$emin)*($eingang-$emin))+$amin[S]readingsSingleUpdate( $hash## "to_set"## int ($y)## 1 )[S]},,delay1,delay1,000000,000000,,,0,0|FreeCmd-AbsCmd2,cmd,cmd,,,delay1,delay1,000000,000000,,,0,0|linearausgang-AbsCmd1,state,no_action,[Linearschalter.to_set],,delay1,delay1,000000,000000,,,0,0 #S .Device_Events -> no_trigger #S .First_init -> done #S .Trigger_Whitelist -> undef #S .Trigger_cmd_off -> no_trigger #S .Trigger_cmd_on -> * #S .Trigger_condition -> #S .Trigger_off -> no_trigger #S .Trigger_on -> no_trigger #S .Trigger_time -> #S .V_Check -> V 0.3 #S Trigger_device -> lineareingang #S Trigger_log -> off #S last_event -> state: 6422 #S state -> active #A MSwitch_Ignore_Types -> notify allowed at watchdog doif fhem2fhem telnet FileLog readingsGroup FHEMWEB autocreate eventtypes readingsproxy svg cul #A MSwitch_Include_MSwitchcmds -> 0 #A MSwitch_Debug -> 0 #A MSwitch_Help -> 0 #A MSwitch_Include_Devicecmds -> 1 #A MSwitch_Extensions -> 0 #A MSwitch_Include_Webcmds -> 0 #A room -> Lineartest #A MSwitch_Inforoom -> MSwitch #A MSwitch_Expert -> 0 #A MSwitch_Lock_Quickedit -