smart gateway: replace magic numbers for threshold by defines