code: def _update_state(self, state_type: str, value: str) -> datetime:
          
          timestamp = datetime.utcnow()
          field = '{}_state'.format(state_type)
          old_state = DB.get_hash_value(self._key, field)
          DB.set_hash_value(self._key, field, value, pipeline=True)
          DB.set_hash_value(self._key, '{}_timestamp'.format(state_type),
                            timestamp.isoformat(), pipeline=True)
          DB.execute()
  
          # Publish an event to notify subscribers of the change in state
          self.publish('{}_state_updated'.format(state_type),
                       event_data=dict(state=value, old_state=old_state))
  
          return timestamp
docs: Update the state of type specified (current or target).
  
          Args:
              state_type(str): Type of state to update, current or target.
              value (str): New state value.
  
          Returns:
              timestamp, current time