Calculate daytime depending energy coast with persistance

Hello
I am not really family with openHAB since I started with openHAB last Christmas. So I hope my questions are not to silly. I use e energy meter connected to openHAB thru modbus binding und rrd4j to store the data. In Switzerland the energy-coast ar daytim-depending (and weekday too :astonished: ). For now I try to calculate the coast with this smal roule. But I think nothing happens. How can I check if the roule is working? Is there a way to start and debug the roule? in …/logs/openhab.log are no entrys. Thanks for any hint.

rule “StromkostenNiedertarif”

when 
	Time cron "0 0 7 * * ?" 
then
	KWH_N_1 = KWH_L1_L2_L3.state as DecimalType
	KWH_N_2 = KWH_L1_L2_L3.historicState(now.minusHours(11)).state as DecimalType 
	KWH_N = KWH_N_1 - KWH_N_2
	KW_CHF_N = KWH_N * NT
end

rule "StromkostenHochtarif"
when
Time cron "0 0 20 * * ?"
then
KWH_H_1 = KWH_L1_L2_L3.state as DecimalType
KWH_H_2 = KWH_L1_L2_L3.historicState(now.minusHours(13)).state as DecimalType
KWH_H = KWH_H_1 - KWH_H_2
KW_CHF_H = KWH_H * HT
end

rule "UpdateKosten"
when
Item KW_CHF_H changed or
Item KW_CHF_N changed
then
KW_CHF_T = KW_CHF_H + KW_CHF_N
KW_CHF.postUpdate(KW_CHF_T)
KW_CHF_T = (0)
KW_CHF_H = (0)
KW_CHF_N = (0)
end

If you add logInfo("Name", "Statement") to your rules it will print a log statement into openhab.log. Sprinkly your log files with these log statements and you will get to see how your rules execute.

I usually either use the name of my rules file or the name of the Rule in place of “Name” and make “Statement” as meaningful and information rich as possible. So print the states of your items, say what the next line is going to do, etc.

Thanks for this info. At the moment I have a much bigger problem. Th SD-Card of the RPi is not accsesible anymore. Guess the card is go on :frowning: Now I think about to Install OH2. How ever this will take some days/weeks