Every power socket has a energy meter integrated, which returns an actual incremental power usage. Now I want to display the power usage per day/month/year. Therefore I created a rule for defining the old and the new day/month/year

   when its 0:00 then
   set $variable_number_day_old = 
   $variable_number_day_actual and set 
   $variable_number_day_actual to     date("DD") and set 
   $variable_number_month_old = 
   $variable_number_month_actual and set 
   $variable_number_month_actual to   
   date ("M") and set 
   $variable_number_year_old = 
   $variable_number_year_actual and set 
    $variable_number_year_actual to 
   date ("YYYY")

and a rule which always adds the power to an overall variable

  when xxx.actualpower changes then 

now I want to calculate the dayly power usage by

   when variable_number_day_actual  changes and variable_number_day_actual not  equal to variable_number_day_old then 

is this correct or any better idea?