# # # 93_PWMR.pm # written by Andreas Goebel 2012-07-25 # e-mail: ag at goebel-it dot de # ############################################## # $Id: # 29.07.15 GA change set manualTempDuration # 21.09.15 GA update, use Log3 and readingsSingleUpdate # 07.10.15 GA initial version published # 07.10.15 GA fix calculation of PWMPulse, default for c_autoCalcTemp # 13.10.15 GA add event-on-change-reading # 14.10.15 GA fix round energyusedp # 15.10.15 GA add a_regexp_on, a regular expression for the on state of the actor # 05.11.15 GA fix new reading desired-temp-until which substitutes modification date of desired-temp in the future # events for desired-temp adjusted (no update of timestamp if temperature stays the same) # 10.11.15 GA fix event for actor change added again, desired-temp notifications adjusted for midnight change # 17.11.15 GA add ReadRoom will now set a reading named temperature containing the last temperature used for calculation # 18.11.15 GA add adjusted energyusedp to be in percent. Now it can be used in Tablet-UI as valve-position # 19.11.15 GA fix move actorState to readings # 22.11.15 GA fix rules on wednesday are now possible (thanks to Skusi) # 22.11.15 GA fix error handling in SetRoom (thanks to cobra112) # 30.11.15 GA fix set reading of desired-temp-used to frost_protect if window is opened # 30.11.15 GA add call PWMR_Attr in PWMR_Define if already some attributes are defined # 26.01.16 GA fix don't call AssignIoPort # 26.01.16 GA fix assign IODev as reference to that hash (otherwise xmllist will crash fhem) # 26.01.16 GA add implementation of PID regulation # 27.01.16 GA add attribute desiredTempFrom to take desiredTemp from another object # 04.02.16 GA add DLookBackCnt, buffer holding previouse temperatures used for PID D-Part calculation # 08.02.16 GA add ILookBackCnt, buffer holding previouse temperatures used for PID I-Part calculation # 08.02.16 GA add valueFormat attribute # 29.06.16 GA add "set frostProtect on|off" # module for PWM (Pulse Width Modulation) calculation # this module defines a room for calculation # it is used by a PWM object # reference to the PWM object is via IODev # PWMR object defines: # IODev: reference to PWM # factor (also used in Pulse calculation): # temperatur difference * factor * cycletime (from PWM) defines on/off periods (pulse) # sensor delivering the temperature (temperature is read from reading using a regexp) # actor to switch on/off the heating devices (may be a structure if more than on actor..) # comma separated list of window contacts followd by ":" and a regular expression # default for the regular expression is "Open" # if the regular expression matches on of the contacts # then readRoom will return c_tempFrostProtect as desired-temp # instead of the current calculated desired-temp # this should cause the calculation routine for the room to switch off heating # # calculation of "desired-temp" is done in a loop (5-minutes default) # - if c_frostProtect is "1" -> set to c_tempFrostProtect # - if c_autoCalcTemp is "1" -> use c_tempN, c_tempD, c_tempC, c_tempE and c_tempRule[1-5] # - c_* variables are syntax checked and derived from attr which have a readable syntax # # - c_tempRule[1-5] are processed in order 5..1 (5 is highes priority) # rules define: # ,[N|D|C] [