Add values to an existing custom entity bundle
One approach is using entity_metadata_wrapper:


  The Entity API provides wrapper classes you may use to make dealing with the values of an entity's properties and fields easier.
  Wrappers make it easier to get and set the values of fields and
  properties as well as to programmatically retrieve additional
  information about these elements and iterate over lists of values in a
  consistent manner.


Example:

$entity_wrapper = entity_metadata_wrapper('myentity', $id);
$var = $entity_wrapper-&gt;field_flag-&gt;value() + 1;
$entity_wrapper-&gt;field_flag-&gt;set($var);
$entity_wrapper-&gt;save();